python - Send one file at a time? -


my python script:

#!/usr/bin/python import cameraid import time import os image="/tmp/image/frame.png"  count = 1 while (count==1):    # make sure file file exists, else show error   if ( not os.path.isfile(image)):     print("error: %s file not found" %image)   else:     print("sending file %s ..." % image)     print cameraid.run()     print os.remove("/tmp/image/frame.png") 

does know how allow file send 1 @ time different filename. once file send, removed instantly.

just make list of files want transfer, iterate on list send files 1 one.

here simple function list of files:

def list_of_files(folder, extension):     '''     return list of file-paths each file folder target extension.     '''     import glob     return glob.glob(str(folder + '*.' + extension)) 

in case be:

files = list_of_files('/tmp/image/','png') image in files:     if ( not os.path.isfile(image)):         print("error: %s file not found" %image)     else:         print("sending file %s ..." % image)         print cameraid.run()         print os.remove(image) 

without function definition:

import glob  files = glob.glob('/tmp/image/*.png')  image in files:     if ( not os.path.isfile(image)):         print("error: %s file not found" %image)     else:         print("sending file %s ..." % image)         print cameraid.run()         print os.remove(image) 

Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -