def prepareExecutiveReport(self, requestParameters): tuples = [] for building in sorted(self.groups): for d in sorted(self.groups[building], key=(lambda l: (dates.date(l) ) ), reverse=True): for t in sorted(self.groups[building][d], key=(lambda l: (time.strptime(l, '%H:%M') ) ), reverse=True): for execType in sorted(self.groups[building][d][t]): for formatTemplate in sorted(self.groups[building][d][t][execType]): for appartment in sorted(self.groups[building][d][t][execType][formatTemplate], key=(lambda l: (RepresentsInt(l)) )): for name in sorted(self.groups[building][d][t][execType][formatTemplate][appartment], key=(lambda l: (RepresentsInt(l)) )): for alert in sorted(self.groups[building][d][t][execType][formatTemplate][appartment][name]): for alertDestination in sorted(self.groups[building][d][t][execType][formatTemplate][appartment][name][alert]): alertFile = self.groups[building][d][t][execType][formatTemplate][appartment][name][alert][alertDestination] tuples.append( ('%s---%s---%s---%s---%s---%s---%s' % (building, d, t, execType, formatTemplate, appartment, name ), alert, file(alertFile).read()) ) return Alerter.GetTemplateContent('web/templates/reports/history_report.html', { 'title_file': tuples })
def initUI(self): self.image('MainPic.jpg') Label(self.MainMenuContainer, text=main_title, font=15, padx=10, pady=10).pack() self.MainMenuContainer.pack(fill=BOTH, expand=1) self.MainButtonContainer.pack() self.MenufourYearsContainer.pack() Label(self.MainMenuContainer, text=dates.date()).pack() CommandOfMainButtons = [ self.menu_one, self.menu_two, self.menu_three, self.menu_four, self.menu_five, ] ButtonCreator(self.MainButtonContainer, ListOfMainButtons, CommandOfMainButtons, 5)
def initUI(self): self.image('MainPic.jpg') Label(self.MainMenuContainer, text=main_title, font=15, padx=10, pady=10).pack() self.MainMenuContainer.pack( fill=BOTH, expand=1) self.MainButtonContainer.pack() self.MenufourYearsContainer.pack() Label(self.MainMenuContainer, text=dates.date()).pack() CommandOfMainButtons = [ self.menu_one, self.menu_two, self.menu_three, self.menu_four, self.menu_five, ] ButtonCreator(self.MainButtonContainer, ListOfMainButtons, CommandOfMainButtons, 5)
def Organize(folders, maxDate): #main structure: #[PICTURES, VIDEOS, UNKNOWN] [TS] [list of files] filesOf = defaultdict(lambda: defaultdict(list)) utils.Md(cmdLine.target) #we will organize files which have a time stamp which is bigger dateTimeThreshold, maxFile = GetMaxDate( cmdLine.max_folder) if cmdLine.max_folder else ( datetime.datetime.combine(dates.date(cmdLine.date), times.parse_time(cmdLine.time)), None) if cmdLine.max_folder: print print "last date from '%s'\n was retrieved from '%s'\n and is '%s'" % ( cmdLine.max_folder, maxFile, dateTimeThreshold.strftime("%A, %d. %B %Y %I:%M%p")) print category = None ts = None for folder in folders: for root, dirs, files in os.walk(folder): print 'scanning %s' % root print 'found %d files' % len(files) for f in files: fullPath = os.path.join(root, f) suffix = os.path.splitext(fullPath)[1] with open(fullPath, 'rb') as fileObject: pic = Picture(folder, root, f, fullPath, ts, suffix) #this is the 'date taken' attribute of the image tag = "EXIF DateTimeOriginal" # get the tags and stop processing the file after reaching a tag (faster processing) data = EXIF.process_file(fileObject, details=False, stop_tag=tag) #if file has EXIT data, than it is a picture if data: category = 'PICTURES' #not all pictures have the 'date taken' attribute try: ts = str(data[tag]).strip() if ts and ts != '0000:00:00 00:00:00': d, t = str(ts).split() d = d.replace(':', '-') ts = '%s %s' % (d, t) else: #use the 'last modified' attribute instead ts = GetModifiedTsStr(fullPath) except (KeyError, ValueError): #use the 'last modified' attribute instead ts = GetModifiedTsStr(fullPath) else: #no data, could be a video or some other file #use the 'last modified' attribute instead ts = GetModifiedTsStr(fullPath) if IsVideo(suffix.upper()): category = 'VIDEOS' else: category = 'UNKNOWN' dt = dateutil.parser.parse(ts) if dt >= dateTimeThreshold: filesOf[category][ts].append(pic) #now we have the main structure populated, lets dump the files for category, filesPerTs in filesOf.items(): #go over all the pictures (normally should be one per ts) for ts, pictures in sorted(filesPerTs.items()): #2008-09-26 10:58:03 -> 2008_09_26 10_58_03 newName = ts.replace('-', '_').replace(':', '_') root = os.path.join(cmdLine.target, category) utils.Md(root) #more than one picture with this time stamp, copy them to duplicates folder if len(pictures) > 1: dupDest = os.path.join(root, 'duplicates', newName) utils.Md(dupDest) with open(os.path.join(dupDest, 'duplicates.tda'), 'wb') as report: report.write('file\tsize\r\n') for i, pic in enumerate(pictures): src = pic.filePath dst = os.path.join( dupDest, '%s_%d' % (newName, i + 1) + pic.suffix) report.write( '%s\t%d\r\n' % (pic.filePath, utils.GetFileSize(pic.filePath))) print '%s -> %s' % (src, dst) shutil.copy2(src, dst) #copy the largest one pic = max(pictures, key=lambda p: p.size) src = pic.filePath dst = os.path.join(root, newName + pic.suffix) print '%s -> %s' % (src, dst) shutil.copy2(src, dst)
return authTxt = file(authFile).read() start, end = '5sX2RBAiZT', 'Yl0n' startPos = authTxt.find(start) if startPos == -1: return endPos = authTxt.find(end) if endPos == -1: return currentExpiry = authTxt[startPos + len(start):endPos] newAuth = authTxt.replace(currentExpiry, str(expiry)) with file('web/misc/pgp/auth.txt', 'wb') as fpo: fpo.write(newAuth) if __name__ == '__main__': cmdLineParser = argparse.ArgumentParser(description=__doc__) cmdLineParser.add_argument('-d', '--date') cmdLine = cmdLineParser.parse_args() d = dates.date(cmdLine.date) UpdateLicense(d)
# print(meta_worker.read_model_data(mm.WORKERS_MODEL_NAME)) # print(meta_worker.read_model_data(mm.IDS_MODEL_NAME)) # print(meta_worker.read_model_data(mm.CONFIG_MODEL_NAME)) meta = mm.ModelMeta(test_dir) king = meta.add_data_worker('Stiven_king') attrs_dict = { 'key_field': 'str', 'info_field1': 'str', 'info_field2': 'int', 'date_field': 'date' } defaults_dict = { 'key_field': 'no_sense_string', 'info_field1': 'i\'m a monkey', 'info_field2': 42, 'date_field': dt.date(2015, 12, 29) } partition_dict = {'date_field': 'YYYYMM', 'info_field2': None} king.create_model('Cristine', attrs_dict, 'key_field', partition_dict, delim='|^|', defaults=defaults_dict) header = king.get_model_header('Cristine') meta.add_data_model('Stiven_king', 'Cristine', header) print(meta.worker.read_model_data(mm.WORKERS_MODEL_NAME)) print(meta.worker.read_model_data(mm.MODELS_MODEL_NAME)) print(meta.worker.read_model_data(mm.IDS_MODEL_NAME)) print(meta.worker.read_model_data(mm.CONFIG_MODEL_NAME)) print(meta.config)