Skip to content

Commit 17d233b

Browse files
committed
correct imports for ubuntu pyqt builds. add --ext to cmdline arguments. default to folder sync
1 parent d3fef6f commit 17d233b

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

.pydevproject

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
<path>/${PROJECT_DIR_NAME}/src</path>
55
</pydev_pathproperty>
66
<pydev_property name="org.python.pydev.PYTHON_PROJECT_VERSION">python 3.0</pydev_property>
7-
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">Python3</pydev_property>
7+
<pydev_property name="org.python.pydev.PYTHON_PROJECT_INTERPRETER">python</pydev_property>
88
</pydev_project>

src/FlashAir/ImageViewer.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,11 @@
4343
##
4444
#############################################################################
4545

46-
from PyQt4 import QtCore, QtGui
46+
import PyQt4.QtCore as QtCore
47+
import PyQt4.QtGui as QtGui
4748
from FlashAir import card
4849
import threading
4950
import time
50-
from QtGui import QScrollArea
51-
5251

5352

5453

@@ -77,7 +76,7 @@ class ScrollAreaEventHandler:
7776
def handler(self, event, scrollarea):
7877
modifiers = QtGui.QApplication.keyboardModifiers()
7978
if modifiers != QtCore.Qt.ControlModifier:
80-
QScrollArea.wheelEvent(scrollarea, event)
79+
QtGui.QScrollArea.wheelEvent(scrollarea, event)
8180
else:
8281
event.ignore()
8382
pass

src/FlashAir/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212

1313
__all__ = ['card','ImageViewer']
1414
from FlashAir import card
15-
from FlashAir import ImageViewer
15+
#from FlashAir import ImageViewer

src/FlashAir/card.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -212,20 +212,22 @@ def download_file(self, remote_location, local_path='', local_file_name=''):
212212
if(os.path.isfile(local_path)):
213213
return (3,0,'')
214214

215-
print("Downloading:" + local_file_name)
215+
print("Downloading:" + local_file_name, end=" ... ")
216216
#get the stuff from the FlashAir
217217
conn.request("GET", remote_location)
218218
download = conn.getresponse()
219-
file = open(local_path, 'wb')
220-
if(download.status==200):
221219

220+
if(download.status==200):
221+
file = open(local_path, 'wb')
222222
while True:
223-
buffer=download.read(1024*8)
223+
buffer=download.read(1024*32)
224224
if not buffer:
225225
break;
226226
file_size += len(buffer)
227227
file.write(buffer)
228228
file.close()
229+
download.close()
230+
print("done (%d bytes) " % file_size)
229231
return (int(download.status!=200), file_size,local_path)
230232

231233
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=['
253255
for entry in outlist:
254256
if ((entry.file_name.split('.')[-1].upper() in extensions) or len(extensions)==0):
255257
self.download_file_list_entry(entry, local_path)
258+
256259

257260
def sync_new_pictures_since_start(self,remote_path='',local_path='',extensions=['JPG']):
258261
last_file=''

src/PyFlashAero.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def ImageView(args):
2020
print("imageView")
2121

2222
try:
23-
from PyQt4 import QtGui
23+
import PyQt4.QtGui as QtGui
2424
except ImportError:
2525
sys.exit("Using --imageViewer requires PyQt4, which is not installed.")
2626

@@ -45,7 +45,7 @@ def SyncFolder(args):
4545
a=card.connection(socket.gethostbyname(args.card_uri.hostname), port, args.timeout)
4646
print("Use ctrl-c to exit!")
4747
while True:
48-
a.sync_new_pictures_since_start(args.folder_remote, args.folder_local)
48+
a.sync_folder_to_remote_folder(args.folder_remote, args.folder_local, extensions=args.ext)
4949
time.sleep(1)
5050
pass
5151

@@ -71,7 +71,7 @@ def SyncFolder(args):
7171

7272
parser.add_argument('--GUIDebugImage', dest='debug_image', help='path for picture to debug the GUI')
7373

74-
74+
parser.add_argument('--ext', action='append', default=['JPG'], dest='ext')
7575

7676
args = parser.parse_args()
7777
ip = socket.gethostbyname(args.card_uri.hostname)
@@ -91,4 +91,4 @@ def SyncFolder(args):
9191

9292
args.processing(args)
9393

94-
94+

0 commit comments

Comments
 (0)