Forum Archive

QNAP NAS - File Station (Code)

parkerc

Hi, I am a complete novice when it comes to programming, but I do my best to try and pick up new things, and the reason I bought Pythonista was because I saw a github post where someone had posted some python scripts on how to work with a QNAP)

https://github.com/mdhorda/qnap/

But while I have copied an pasted the content over, into a new folder called QNAP, it does not seem to work ?

I'm particularly interested in one of the python scripts here - > https://github.com/mdhorda/qnap/blob/master/get_sid.py as I want to find a way that it can be run, so it asked me for me password and encodes it for me etc.

Any help would be appreciated

ccc

Add these lines to the bottom of get_sid.py and run it.

if __name__ == '__main__':
    import console
    print(ezEncode(console.password_alert('Enter your password')))
parkerc

Many thanks !!

Any help you could give me on making the rest of it work would be appreciated..

brumm

Hi parkerc,

first you should download all py files in the same dir (site-packages or where you write your qnap program). Then you have to write your program (not in site-packages dir). Btw. I don't own a QNAP so I can't test it...

from filestation import *

#and now follow the README.md sample
host = 'your_host_or_ip_addr'
user = 'your_user'
password = 'your_password'

filestation = FileStation(host, user, password)
shares = filestation.list_share()
#and now you should start with list or search command...

edit: First line corrected.

parkerc

Hi,

Thanks for the update ;)

Ok, I've copied everything I could from that GitHub post in to a folder called QNAP, and then created a new script with what you had provided above and put that outside.

So I now have a new qnaprun.py file next to the QNAP folder.

However - When I run the qnaprun.py script I get an immediate "syntaxerror : invalid syntax on the first line ? Which is

from filestation import

** I understand you do not have a QNAP, hence your support is very much appreciated .

brumm

I can't see a * at the end of the first line!?
And if you don't use the site-packages dir, your code have to be in the same dir (QNAP).
modules

brumm

I tested it with my localhost and it shows an expected error.

ERROR:root:GET error: http://127.0.0.1:8080/cgi-bin/authLogin.cgi?pwd=eW91cl9wYXNzd29yZA==&user=your_user
...

So it should work with a Qnap at the other side.

parkerc

Hi, I have put everything into the same folder now (called Qnap ) but whenever I run that file I continue to get the same syntax error on the first line - yet there is a file in the folder called filestation.py ?

Here is the qnaprun.py

from filestation import

#and now follow the README.md sample
host = '10.168.1.111'
user = 'your_user'
password = 'your_password'

filestation = FileStation(host, user, password)
shares = filestation.list_share()
#and now you should start with list or search command...
ccc

Add an * to the end of that the first line.