Skip to content

Commit

Permalink
Name change to not interfere with brandnames
Browse files Browse the repository at this point in the history
Add readme text
add comments in init
  • Loading branch information
Christian Holl committed Jan 5, 2014
1 parent bc39be7 commit 5af67cd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 22 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
17 changes: 17 additions & 0 deletions src/PyFlashAero/__init__.py
Original file line number Diff line number Diff line change
@@ -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
14 changes: 8 additions & 6 deletions src/PyFlashAir/flashair.py → src/PyFlashAero/flashair.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
'''
Created on Jan 4, 2014
@author: cyborg-x1
Licence: GNU AGPL
@author: Christian Holl
'''

import os
Expand Down Expand Up @@ -83,7 +85,6 @@ def __init__(self, host, port, timeout):
'''
Constructor
'''
print("init")
self.host=host
self.port=port
self.timeout=timeout
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(",")
Expand All @@ -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,'')
Expand All @@ -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()
Expand Down
16 changes: 0 additions & 16 deletions src/PyFlashAir/__init__.py

This file was deleted.

0 comments on commit 5af67cd

Please sign in to comment.