From 5af67cdeabbff3fcd5a62cc1ef8af35c20c891fa Mon Sep 17 00:00:00 2001 From: Christian Holl Date: Mon, 6 Jan 2014 00:38:40 +0100 Subject: [PATCH] Name change to not interfere with brandnames Add readme text add comments in init --- README.md | 6 ++++++ src/PyFlashAero/__init__.py | 17 +++++++++++++++++ src/{PyFlashAir => PyFlashAero}/flashair.py | 14 ++++++++------ src/PyFlashAir/__init__.py | 16 ---------------- 4 files changed, 31 insertions(+), 22 deletions(-) create mode 100644 src/PyFlashAero/__init__.py rename src/{PyFlashAir => PyFlashAero}/flashair.py (97%) delete mode 100644 src/PyFlashAir/__init__.py diff --git a/README.md b/README.md index e69de29..c86f6f2 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,6 @@ +A downloader written in python for the Toshiba FlashAir Wifi SDHC Cards. + +Currently using a setup of Hostname/IP, remote_folder and download directory requires a modification of the __init__.py. +When started the script looks for the card on the given Host/IP if it is able to connect it, it gets the filelist by command.cgi +and checks for every file inside the download directory, if a file is not present, it will be downloaded. This continues as +long as the script is running, terminate it with CTRL-C. \ No newline at end of file diff --git a/src/PyFlashAero/__init__.py b/src/PyFlashAero/__init__.py new file mode 100644 index 0000000..a8947b6 --- /dev/null +++ b/src/PyFlashAero/__init__.py @@ -0,0 +1,17 @@ +''' +Created on Jan 4, 2014 + +Licence: GNU AGPL + +@author: Christian Holl +''' +from PyFlashAero import flashair +import time + +if __name__ == '__main__': + # Host/IP Port Timeout + a=flashair.connection('192.168.0.16', 80,1000) + while True: + # REMOTE_FOLDER DOWNLOAD DIRECTORY + a.sync_folder_to_remote_folder('/DCIM/', '/downloaddir') + pass \ No newline at end of file diff --git a/src/PyFlashAir/flashair.py b/src/PyFlashAero/flashair.py similarity index 97% rename from src/PyFlashAir/flashair.py rename to src/PyFlashAero/flashair.py index e4dd203..607f7a2 100644 --- a/src/PyFlashAir/flashair.py +++ b/src/PyFlashAero/flashair.py @@ -1,7 +1,9 @@ ''' Created on Jan 4, 2014 -@author: cyborg-x1 +Licence: GNU AGPL + +@author: Christian Holl ''' import os @@ -83,7 +85,6 @@ def __init__(self, host, port, timeout): ''' Constructor ''' - print("init") self.host=host self.port=port self.timeout=timeout @@ -134,7 +135,8 @@ def send_command(self, opcode, directory='', date=-1, addr=-1, data=(), length=- print("Firmware is: ") print(self.fwversion) else: - print("ERROR: Could not determine firmware version!") + if(ret!=-2): + print("ERROR: Could not determine firmware version!") return(-1,'') if(opcode[7]): #must be bigger than or equal to firmware version @@ -169,9 +171,7 @@ def get_file_list(self,directory): lines=lines[1:-1] #skip headline, and current dir at the end else: return (0,()) - - - print(lines) + outlst=[] for file in lines: e=file.split(",") @@ -193,6 +193,7 @@ def download_file(self, remote_location, local_path='', local_file_name=''): local_file_name = remote_location.split('/')[-1] file_size=0 + #does folder exist? if(not os.access(local_path, os.R_OK)): return (2,0,'') @@ -208,6 +209,7 @@ def download_file(self, remote_location, local_path='', local_file_name=''): if(os.path.isfile(local_path)): return (3,0,'') + print("Downloading:" + local_file_name) #get the stuff from the FlashAir conn.request("GET", remote_location) download = conn.getresponse() diff --git a/src/PyFlashAir/__init__.py b/src/PyFlashAir/__init__.py deleted file mode 100644 index 3f333be..0000000 --- a/src/PyFlashAir/__init__.py +++ /dev/null @@ -1,16 +0,0 @@ -''' -Created on Jan 4, 2014 - -@author: cyborg-x1 -''' -from PyFlashAir import flashair -import time - -if __name__ == '__main__': - a=flashair.connection('192.168.0.16', 80,1000) - #print(a.send_command(flashair.command.Get_file_list,directory='/')) - while True: - print('sync') - a.sync_folder_to_remote_folder('/DCIM/101EOS5D', '/home/cyborg-x1/dwhelper') - time.sleep(1) - pass \ No newline at end of file