Any way to work with SFTP?

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
NoFanru
Newbie
Posts: 22
Joined: Wed Jun 21, 2023 3:34 am
Projects: Yandere pjSEKAI boys (Yandere Rui)
Discord: nofanru
Contact:

Any way to work with SFTP?

#1 Post by NoFanru »

I really need the ability to send data to an SFTP server

I tried to use the paramiko library.
I installed it, as stated in the documentation, in the game/python-packages folder, tried to import it in the init python block, as well as in a separate .py file and imported this file to call the function, in all cases the game just crashes without any errors. I also tried to import only parts, like paramiko.Transport, but that also didn’t give anything

So now I'm stumped and have no idea what to do about it. I would be grateful for any help!



Updated: If I understand correctly, then for paramiko to work I need to compile my own version of renpy from source code. I still hope to find an easier way :<
Last edited by NoFanru on Sun May 26, 2024 1:34 pm, edited 1 time in total.

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Any way to work with SFTP?

#2 Post by giorgi1111 »

I think error happens before game starts. Make code such to start game and then call that code.if error happens renpy ll show it.and you cant use all python modules in renpy. I searched earlier and they saying only pure python works.search pure python sftp and try it

NoFanru
Newbie
Posts: 22
Joined: Wed Jun 21, 2023 3:34 am
Projects: Yandere pjSEKAI boys (Yandere Rui)
Discord: nofanru
Contact:

Re: Any way to work with SFTP?

#3 Post by NoFanru »

giorgi1111 wrote: Sun May 26, 2024 10:00 am I think error happens before game starts. Make code such to start game and then call that code.if error happens renpy ll show it.and you cant use all python modules in renpy. I searched earlier and they saying only pure python works.search pure python sftp and try it
Thanks for the answer
I created a function where the library is imported. The game starts, but when it reaches the execution of this function it also crashes without any error (log, traceback, errors also do not change)

Pure python sftp sounds good, but everything I find on the internet comes down to poramiko :<

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Any way to work with SFTP?

#4 Post by giorgi1111 »

Show code where you using function. Im using renpy 8.0.3 . I put pymysql in renpy8.0.3/lib/python3.9 and importing straight import pymysql. Also for first use for test i calling it earlier and game was starting and crashing without error.then used where i needed mysql function and it was showing errors.now if xampp isnot launched game crashes at start but showing error in text file.

NoFanru
Newbie
Posts: 22
Joined: Wed Jun 21, 2023 3:34 am
Projects: Yandere pjSEKAI boys (Yandere Rui)
Discord: nofanru
Contact:

Re: Any way to work with SFTP?

#5 Post by NoFanru »

giorgi1111 wrote: Sun May 26, 2024 10:46 am Show code where you using function. Im using renpy 8.0.3 . I put pymysql in renpy8.0.3/lib/python3.9 and importing straight import pymysql. Also for first use for test i calling it earlier and game was starting and crashing without error.then used where i needed mysql function and it was showing errors.now if xampp isnot launched game crashes at start but showing error in text file.
I simply wrote import paramiko in the function:

Code: Select all

init python:
    def f():
        import paramiko
Later in the game I just called this function and the game crashes

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Any way to work with SFTP?

#6 Post by giorgi1111 »

Put this in rpy

init python:

import paramiko
Def f():
Some code
Label something:
$ f()
This in rpy you need this function and where need
Call f in rpy. $ f()
Maybe evrything in one file.use import at the begining

NoFanru
Newbie
Posts: 22
Joined: Wed Jun 21, 2023 3:34 am
Projects: Yandere pjSEKAI boys (Yandere Rui)
Discord: nofanru
Contact:

Re: Any way to work with SFTP?

#7 Post by NoFanru »

giorgi1111 wrote: Sun May 26, 2024 11:35 am init python:

import paramiko
Def f():
Some code

Call f in rpy. $ f()
The game crashes due to import paramiko. By writing this directly in init python it doesn’t even start

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Any way to work with SFTP?

#8 Post by giorgi1111 »

That is same error at the begining or middle but import neednot to define in function.import paramiko and then use it to define function you need for something using paramiko functions.

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Any way to work with SFTP?

#9 Post by giorgi1111 »

Example:
Init python:
import paramiko
Def something():
local_file_path = '<your_local_file_path>'
remote_file_path = '<your_remote_file_path>'

ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect( \
hostname = '<your_hostname>', \
username = 'busde',
key_filename = ssh_key_path
)

ftp_client = ssh_client.open_sftp()
ftp_client.put(local_file_path, remote_file_path)

ftp_client.close()
ssh_client.close()
Label something:
$ something()

NoFanru
Newbie
Posts: 22
Joined: Wed Jun 21, 2023 3:34 am
Projects: Yandere pjSEKAI boys (Yandere Rui)
Discord: nofanru
Contact:

Re: Any way to work with SFTP?

#10 Post by NoFanru »

giorgi1111 wrote: Sun May 26, 2024 11:59 am Example:
Init python:
import paramiko
Def something():
local_file_path = '<your_local_file_path>'
remote_file_path = '<your_remote_file_path>'

ssh_client = paramiko.SSHClient()
ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh_client.connect( \
hostname = '<your_hostname>', \
username = 'busde',
key_filename = ssh_key_path
)

ftp_client = ssh_client.open_sftp()
ftp_client.put(local_file_path, remote_file_path)

ftp_client.close()
ssh_client.close()
Label something:
$ something()
I'm trying to do something like this, all my code is in a script:

Code: Select all

init python:
    import paramiko

    def f():
        host = "<host>"
        port = <port>
        transport = paramiko.Transport((host, port))
        transport.connect(username='<user>', password='<password>')
        sftp = paramiko.SFTPClient.from_transport(transport)

        remotepath = 'test.txt'
        localpath = 'C:/Users/Admin/Desktop/test.txt'

        sftp.get(remotepath, localpath)
        sftp.put(localpath, remotepath)

        sftp.close()
        transport.close()
    
label start:

    scene bg room

    e "Blah blah blah"

    $ f()

    e "Blah?"

    return
The game just won't start, even if I remove the function and leave only init python: import paramiko

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Any way to work with SFTP?

#11 Post by giorgi1111 »

I dont using sftp. If you know your code is good then it is module problem .try with other sftp module

giorgi1111
Regular
Posts: 83
Joined: Sat May 04, 2024 10:40 pm
Contact:

Re: Any way to work with SFTP?

#12 Post by giorgi1111 »

Now i see paramiko needs install .even if put all required modules yourself i dont think it works.

NoFanru
Newbie
Posts: 22
Joined: Wed Jun 21, 2023 3:34 am
Projects: Yandere pjSEKAI boys (Yandere Rui)
Discord: nofanru
Contact:

Re: Any way to work with SFTP?

#13 Post by NoFanru »

I did a little searching on the Internet and, as I understand it, paramiko uses pyCrypto, which has a lot of C-extension modules. And from what I found on the Internet, if I understand correctly, to implement this library I need to build renpy from source?

If this is the case, then it is sad, this all seems out of my level of knowledge and I really don't want to deal with it...

Still hoping to find an easier way

Post Reply

Who is online

Users browsing this forum: Ocelot