ftp_pwd, timeout=ftp_maxtime) session.cwd(ftp_directory) file = open(media, 'rb') Log.printandlog("Sending File: " + media_name) session.storbinary('STOR ' + media_name, file) file.close() Log.printandlog("file sent to ftp") #move the file os.rename(media, os.path.join(longterm_stor_path, media_name)) Log.printandlog( "Successful: File sent, local file has been moved to folder 'ftpd_vidoes'" ) session.quit() except Exception as e: Log.printandlog(str(e)) Log.printandlog("an error occured for file: " + os.path.basename(media)) #execute the function if the script is being explicitly called (and not imported as a module into other code) if __name__ == "__main__": #**************************************************************************** #set logging file Log.initiatelog("FTPMedialog") FtpNewmedias()
import logging import time import argparse import RPi.GPIO as GPIO #import local libraries import CBlib.POEcommands as POEcommands import CBlib.AXIS as AXIS import CBlib.Log as Log import CBlib.FFMPEG as FFMPEG #execute the function if the script is being explicitly called (and not imported as a module into other code) if __name__ == "__main__": #**************************************************************************** Log.initiatelog("GrabMedia") #get the option arguments from commandline parser = argparse.ArgumentParser() parser.add_argument("--camera", help="integer to decide what camera to use (1-4)", type=int) args = parser.parse_args() #If camera is specified, use that. otherwise default to camera 1 if args.camera: Cam = args.camera else: Cam = 1 CamString = 'Camera' + str(Cam)