diff --git a/.pydevproject b/.pydevproject index 29cb7bf..fd053e7 100644 --- a/.pydevproject +++ b/.pydevproject @@ -4,5 +4,5 @@ /${PROJECT_DIR_NAME}/src python 3.0 -Python3 +python diff --git a/src/FlashAir/ImageViewer.py b/src/FlashAir/ImageViewer.py index 0658923..304cabd 100644 --- a/src/FlashAir/ImageViewer.py +++ b/src/FlashAir/ImageViewer.py @@ -43,12 +43,11 @@ ## ############################################################################# -from PyQt4 import QtCore, QtGui +import PyQt4.QtCore as QtCore +import PyQt4.QtGui as QtGui from FlashAir import card import threading import time -from QtGui import QScrollArea - @@ -77,7 +76,7 @@ class ScrollAreaEventHandler: def handler(self, event, scrollarea): modifiers = QtGui.QApplication.keyboardModifiers() if modifiers != QtCore.Qt.ControlModifier: - QScrollArea.wheelEvent(scrollarea, event) + QtGui.QScrollArea.wheelEvent(scrollarea, event) else: event.ignore() pass diff --git a/src/FlashAir/__init__.py b/src/FlashAir/__init__.py index 4a196ea..6127cb1 100644 --- a/src/FlashAir/__init__.py +++ b/src/FlashAir/__init__.py @@ -12,4 +12,4 @@ __all__ = ['card','ImageViewer'] from FlashAir import card -from FlashAir import ImageViewer \ No newline at end of file +#from FlashAir import ImageViewer diff --git a/src/FlashAir/card.py b/src/FlashAir/card.py index 0d42895..d30275d 100644 --- a/src/FlashAir/card.py +++ b/src/FlashAir/card.py @@ -212,20 +212,22 @@ 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) + print("Downloading:" + local_file_name, end=" ... ") #get the stuff from the FlashAir conn.request("GET", remote_location) download = conn.getresponse() - file = open(local_path, 'wb') - if(download.status==200): + if(download.status==200): + file = open(local_path, 'wb') while True: - buffer=download.read(1024*8) + buffer=download.read(1024*32) if not buffer: break; file_size += len(buffer) file.write(buffer) file.close() + download.close() + print("done (%d bytes) " % file_size) return (int(download.status!=200), file_size,local_path) def download_file_list_entry(self, entry,local_path='', local_filename=''): @@ -253,6 +255,7 @@ def sync_folder_to_remote_folder(self,remote_path='',local_path='',extensions=[' for entry in outlist: if ((entry.file_name.split('.')[-1].upper() in extensions) or len(extensions)==0): self.download_file_list_entry(entry, local_path) + def sync_new_pictures_since_start(self,remote_path='',local_path='',extensions=['JPG']): last_file='' diff --git a/src/PyFlashAero.py b/src/PyFlashAero.py index 857dae7..88b9d07 100644 --- a/src/PyFlashAero.py +++ b/src/PyFlashAero.py @@ -20,7 +20,7 @@ def ImageView(args): print("imageView") try: - from PyQt4 import QtGui + import PyQt4.QtGui as QtGui except ImportError: sys.exit("Using --imageViewer requires PyQt4, which is not installed.") @@ -45,7 +45,7 @@ def SyncFolder(args): a=card.connection(socket.gethostbyname(args.card_uri.hostname), port, args.timeout) print("Use ctrl-c to exit!") while True: - a.sync_new_pictures_since_start(args.folder_remote, args.folder_local) + a.sync_folder_to_remote_folder(args.folder_remote, args.folder_local, extensions=args.ext) time.sleep(1) pass @@ -71,7 +71,7 @@ def SyncFolder(args): parser.add_argument('--GUIDebugImage', dest='debug_image', help='path for picture to debug the GUI') - + parser.add_argument('--ext', action='append', default=['JPG'], dest='ext') args = parser.parse_args() ip = socket.gethostbyname(args.card_uri.hostname) @@ -91,4 +91,4 @@ def SyncFolder(args): args.processing(args) - \ No newline at end of file +