Skip to content

Commit

Permalink
Merge pull request #13 from tadejs/sync
Browse files Browse the repository at this point in the history
correct imports for ubuntu pyqt builds. add --ext to cmdline arguments. ...
  • Loading branch information
cyborg-x1 committed Jan 28, 2015
2 parents d3fef6f + 17d233b commit 1b94b54
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .pydevproject
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
<path>/${PROJECT_DIR_NAME}/src</path>
</pydev_pathproperty>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Python3</pydev_property>
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>
</pydev_project>
7 changes: 3 additions & 4 deletions src/FlashAir/ImageViewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -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




Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/FlashAir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@

__all__ = ['card','ImageViewer']
from FlashAir import card
from FlashAir import ImageViewer
#from FlashAir import ImageViewer
11 changes: 7 additions & 4 deletions src/FlashAir/card.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=''):
Expand Down Expand Up @@ -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=''
Expand Down
8 changes: 4 additions & 4 deletions src/PyFlashAero.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand All @@ -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

Expand All @@ -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)
Expand All @@ -91,4 +91,4 @@ def SyncFolder(args):

args.processing(args)



0 comments on commit 1b94b54

Please sign in to comment.