def run_eclipse(readfile, writefile, interval): cam_list, min_start, max_end = create_cam_list(readfile) duration = max_end - min_start f = open(writefile, 'w') f.write('Camera_ID,is_Video,Duration(secs),Interval,\ StoreCAM_ID,URL,O/P Filename,Runtime(secs),FPS\n') for cam in cam_list: f.write('{0:d},,{1:d},{2:d},,,,,\n'.format(cam, duration, interval)) f.close() cur_time = get_time() if (cur_time > max_end): print('Eclipse has already ended. Terminating execution.') return try: while (cur_time < min_start - 120): # provide 2 minutes to prep sys.stdout.write('\rWaiting for Eclipse to start in {0:d} seconds'\ .format(min_start - cur_time)) sys.stdout.flush() cur_time = get_time() except KeyboardInterrupt: sys.stdout.write('\nKeyboard Interrupt detected.') sys.stdout.write(' Terminating execution.\n') return print('') try: archiver.archiver(['archiver.py', '-f', writefile]) except KeyboardInterrupt: print('Keyboard Interrupt detected. Terminating execution.') else: print('Eclipse is over. Terminating execution')
def test_archiver(self): """Tests if files are archived in the correct format and subdirectories""" archiver.archiver(self.dirname) expected = [] for i in self.filenames: item = os.path.join(os.path.basename(self.dirname),i) item = item.replace('\\','/') expected.append(item) zf = zipfile.ZipFile(self.archivename) observed = zf.namelist() self.assertEqual(observed,expected,'oops!')
def test_archiver(self): """Tests if files are archived in the correct format and subdirectories""" archiver.archiver(self.dirname) expected = [] for i in self.filenames: item = os.path.join(os.path.basename(self.dirname), i) item = item.replace('\\', '/') expected.append(item) zf = zipfile.ZipFile(self.archivename) observed = zf.namelist() self.assertEqual(observed, expected, 'oops!')
def main(args): print(args) try: assert len(args) == 4 inFile = args[1] duration = int(args[2]) interval = float(args[3]) except: print( "Call Syntax: python archiveList.py <Input File> <Duration> <Interval>" ) return try: f = open(inFile, "r") id_list = list(f) except: print("Input File couldn't be opened") return start_timestamp = time.time() while (time.time() - start_timestamp) < duration: frame_timestamp = time.time() for cam in id_list: cam = re.search(r'(?P<ID>[\d]*) (?P<Type>[\S]*)', cam) argsIN = [None, cam.group("ID"), cam.group("Type"), 1, 1] try: Archiver.archiver(argsIN) except Exception, e: print e # Sleep until the interval between frames ends. time_to_sleep = interval - (time.time() - frame_timestamp) if time_to_sleep > 0: time.sleep(time_to_sleep)
def configure(self, env): import params env.set_params(params) archiver()
opts, args = getopt(sys.argv[1:], 'pm') conf = config() # archive type S = single file, P = preserve (all reqs), M = mirror arctype = 'S' # TODO implement -p --preserver option for opt in opts[:]: if opt[0] == '-p': conf.setopt('preserve', True) arctype = 'P' elif opt[0] == '-m': conf.setopt('mirror', True) arctype = 'M' wa = archiver() wa.setconfig( conf ) historyfile = conf.getopt('wapath') + "/.history" hist = open(historyfile, 'a') count = 0 for url in args[:]: stat = wa.fetch(url) if stat > 0: print >> sys.stderr, "wa %s failed" % url else: hist.write(arctype + ' ' + strftime('%Y-%m-%d-%X') + ' ' + url + '\n') count = count + 1 hist.close()
def main(folder, config): filePassDict = {} #list to hold file names (without extensions) in the folder filePassDict = archiver.fileListGen(folder, config) #generates a list of all (unique) file names (without extensions) in the folder (srt, video files are not doubly listed) archiver.archiver(folder, filePassDict, config)
def archive_output(self): #Firing up archiver to check files and create zip. archiver(self.out_path, self.project_name, self.out_file_list)