1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
class IOcamera(object):
def __init__(self):
#some arguments
def get_images(self, rep, bind, r=None):
"""Download files from current camera.
keyword arguments:
rep -- folder to download files.
bind -- QPlainTextEdit object
r -- range of files
"""
old_rep = os.getcwd()
os.chdir(rep)
MEM, sys.stdout = sys.stdout, STDOUT(bind)
if r:
subprocess.Popen(["gphoto2", "--get-file", r], universal_newlines=True,
stdout=sys.stdout).communicate()
else:
subprocess.Popen(["gphoto2", "--get-all-files"], universal_newlines=True,
stdout=sys.stdout).communicate()
os.chdir(old_rep)
sys.stdout = MEM
return "Done"
class STDOUT(object):
def __init__(self, bind):
self.bind = bind
def fileno(self):
print "fileno"
pass
def write(self, text):
text = text + "file"
self.bind.appendPlainText(text)
QtCore.QCoreApplication.processEvents() |
Partager