def on_discard(self, event_): name = self.names[self.index] day = tools.get_day() if not os.path.exists('discard/{}'.format(day)): os.mkdir('discard/{}'.format(day)) os.rename('infiles/' + name, 'discard/{}/{}'.format(day, name)) self.load_next_image()
def on_discard(self, _event): name = self.names[self.index] day = tools.get_day() if not os.path.exists(os.path.join('discard', day)): os.mkdir(os.path.join('discard', day)) os.rename(os.path.join('infiles', name), os.path.join('discard', day, name)) self.load_next_image()
def on_discard(self, _event): name = self.names[self.index] day = tools.get_day() tools.mkdir_p(os.path.join('discard', day)) os.rename(os.path.join('infiles', name), os.path.join('discard', day, name)) self.load_next_image()
def on_process(self, _event): if self.static_image.validate_image(): day = tools.get_day() timeid = time.strftime('%H%M%S', time.localtime()) infile = self.names[self.index] process_calendar.process(infile, day, timeid) out_path = os.path.join('outfiles', day, '{}.jpg'.format(timeid)) os.rename(os.path.join('infiles', infile), out_path) self.load_next_image()
def run(): names = os.listdir("infiles/") names.sort() for infile in names: day = tools.get_day() timeid = day + "/" + raw_input("Time id: ") group_name = raw_input("Group name: ") process(infile, group_name, timeid) os.rename("infiles/" + infile, "outfiles/{}_{}.jpg".format(timeid, tools.safe_filename(group_name)))
def run(): names = os.listdir('infiles') names.sort() for infile in names: day = tools.get_day() timeid = raw_input('Time id: ') group_name = raw_input('Group name: ') process(infile, group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) os.rename(os.path.join('infiles', infile), os.path.join('outfiles', day, outfile_name))
def run(): names = os.listdir('infiles/') names.sort() for infile in names: day = tools.get_day() timeid = day + '/' + raw_input('Time id: ') group_name = raw_input('Group name: ') #timeid = time.strftime('%a/%H%M%S', time.localtime()) Process.process(infile, group_name, timeid) os.rename('infiles/' + infile, 'outfiles/{}_{}.jpg'.format(timeid, tools.safe_filename(group_name))) print 'Finished.'
def on_restore(self, _event): cwd = os.getcwd() day = tools.get_day() initial_dir = os.path.join(cwd, 'discard', day) if not os.path.exists(initial_dir): initial_dir = os.path.join(cwd, 'discard') tools.mkdir_p(initial_dir) dlg = wx.lib.imagebrowser.ImageDialog(self, initial_dir) dlg.Centre() if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetFile() self.static_image.load_from_file(self.filename) dlg.Destroy()
def on_open(self, _event): cwd = os.getcwd() day = tools.get_day() initial_dir = os.path.join(cwd, 'png', day) if not os.path.exists(initial_dir): initial_dir = os.path.join(cwd, 'png') if not os.path.exists(initial_dir): os.mkdir(initial_dir) dlg = wx.lib.imagebrowser.ImageDialog(self, initial_dir) dlg.Centre() if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetFile() self.static_image.load_from_file(self.filename) dlg.Destroy()
def on_restore(self, event_): cwd = os.getcwd() day = tools.get_day() initial_dir = os.path.join(cwd, 'discard/{}'.format(day)) if not os.path.exists(initial_dir): initial_dir = os.path.join(cwd, 'discard') if not os.path.exists(initial_dir): os.mkdir(initial_dir) dlg = wx.lib.imagebrowser.ImageDialog(self, initial_dir) dlg.Centre() if dlg.ShowModal() == wx.ID_OK: self.filename = dlg.GetFile() self.static_image.load_from_file(self.filename) dlg.Destroy()
def getAlarmEcs(): ecslists = aliyunecs.getAllaccountEcslist() alarmEcs = [] currentDay = tools.get_day() for i in ecslists: days = int(tools.day_cmp(i[7], currentDay)) if ((dayIn(days)) and (i[12] == False)): alarmEcs.append(addLine(i)) alarmEcs.sort(key=lambda ecs: ecs[3]) return alarmEcs
def process(infile, group_name, timeid): page = Image.open("infiles/" + infile) photo_size = (A4_WIDTH * 3 / 4, A4_HEIGHT * 3 / 4) photo_left = (A4_WIDTH - photo_size[0]) / 2 photo_top = (A4_HEIGHT - photo_size[1]) / 2 - A4_HEIGHT / 64 photo_right = photo_left + photo_size[0] photo_bottom = photo_top + photo_size[1] photo_rect = (photo_left, photo_top, photo_right, photo_bottom) create_title(page, (A4_WIDTH, A4_HEIGHT), photo_rect, group_name) day = tools.get_day() if not os.path.exists("png/{}".format(day)): os.mkdir("png/{}".format(day)) png_file = "png/{}_{}.jpg".format(timeid, tools.safe_filename(group_name)) page.save(png_file, quality=75) tools.print_image(png_file)
def on_process(self, _event): if self.validate(): day = tools.get_day() timeid = time.strftime('%H%M%S', time.localtime()) infile = self.names[self.index] infile_path = os.path.join('infiles', infile) group_name = self.group_name.GetValue() num_copies = self.num_copies.GetValue() if num_copies != '': process.process(infile_path, group_name, day, timeid, int(num_copies)) # pylint: disable=too-many-function-args else: process.process(infile_path, group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) outfile_path = os.path.join('outfiles', day, outfile_name) os.rename(infile_path, outfile_path) self.load_next_image()
def getEcslist(): ecslists =aliyunecs.getAllaccountEcslist() ecslists.sort(key=lambda ecs:ecs[7]) Ecslist=[] currentDay=tools.get_day() for i in ecslists: days=int(tools.day_cmp(i[7],currentDay)) if ((dayIn(days)) and (i[12]==False)): Ecslist.append(addLine(i)) else: Ecslist.append(addLine(i,False,False)) Ecslist.insert(0,['账号','服务器','带宽','内网IP','CPU','MEM','到期日','类型','系统','状态','区域','是否过期']) Ecslist.append(['账号','服务器','带宽','内网IP','CPU','MEM','到期日','类型','系统','状态','区域','是否过期']) return Ecslist
def on_get_photos(self, _event): if not tools.mount_camera(): self.SetStatusText('Could not connect to camera. Try again.') tools.get_camera_files() if tools.umount_camera(): self.SetStatusText('You can disconnect the camera now.') else: self.SetStatusText('Could not disconnect from camera.') names = os.listdir('infiles') names.sort() day = tools.get_day() tools.mkdir_p(os.path.join('outfiles', day)) self.names = names if len(self.names) > 0: self.load_image(0) else: self.next_btn.Disable() self.prev_btn.Disable() self.load_blank()
def run(): if not tools.mount_camera(): print 'Could not connect to camera. Try again.' tools.get_camera_files() if tools.umount_camera(): print 'You can disconnect the camera now.' else: print 'Could not disconnect from camera. Please use the software ' \ 'safely remove function before disconnecting.' names = os.listdir('infiles') names.sort() for infile in names: day = tools.get_day() #group_name = raw_input('Group name: ') timeid = time.strftime('%H%M%S', time.localtime()) process(infile, day, timeid) outfile_name = '{}.jpg'.format(timeid) os.rename(os.path.join('infiles', infile), os.path.join('outfiles', day, outfile_name)) print "Finished."
def on_get_photos(self, event_): if not tools.mount_camera(): self.SetStatusText('Could not connect to camera. Try again.') tools.get_camera_files() if tools.umount_camera(): self.SetStatusText('You can disconnect the camera now.') else: self.SetStatusText('Could not disconnect from camera.') names = os.listdir('infiles/') names.sort() day = tools.get_day() if not os.path.exists('outfiles/{}'.format(day)): os.mkdir('outfiles/{}'.format(day)) self.names = names if len(self.names) > 0: self.load_image(0) else: self.next_btn.Disable() self.prev_btn.Disable() self.load_blank()
def on_process(self, _event): if self.validate(): if self.keep_timeid.GetValue(): day = os.path.basename(os.path.dirname(self.filename)) timeid = os.path.basename(self.filename)[0:6] else: day = tools.get_day() timeid = time.strftime('%H%M%S', time.localtime()) infile = self.filename group_name = self.group_name.GetValue() num_copies = self.num_copies.GetValue() if num_copies != '': process.process(infile, group_name, day, timeid, int(num_copies)) # pylint: disable=too-many-function-args else: process.process(infile, group_name, day, timeid) out_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) out_path = os.path.join('outfiles', day, out_name) shutil.copyfile(self.filename, out_path)
def run(): if not tools.mount_camera(): print 'Could not connect to camera. Try again.' tools.get_camera_files() if tools.umount_camera(): print 'You can disconnect the camera now.' else: print 'Could not disconnect from camera.' names = os.listdir('infiles') names.sort() day = tools.get_day() if not os.path.exists(os.path.join('outfiles', day)): os.mkdir(os.path.join('outfiles', day)) for infile in names: group_name = raw_input('Group name: ') timeid = time.strftime('%H%M%S', time.localtime()) process(os.path.join('infiles', infile), group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) os.rename(os.path.join('infiles', infile), os.path.join('outfiles', day, outfile_name)) print 'Finished.'
def run(): if not tools.mount_camera(): print 'Could not connect to camera. Try again.' tools.get_camera_files() if tools.umount_camera(): print 'You can disconnect the camera now.' else: print 'Could not disconnect from camera.' names = os.listdir('infiles') names.sort() day = tools.get_day() tools.mkdir_p(os.path.join('outfiles', day)) for infile in names: group_name = raw_input('Group name: ') timeid = time.strftime('%H%M%S', time.localtime()) process(os.path.join('infiles', infile), group_name, day, timeid) outfile_name = '{}_{}.jpg'.format(timeid, tools.safe_filename(group_name)) os.rename(os.path.join('infiles', infile), os.path.join('outfiles', day, outfile_name)) print 'Finished.'
def process(infile, timeid): try: page = Image.open('base/Calendar_2014.png') except IOError: print "Cannot open calendar page base" return photo_size = (A4_WIDTH * 3 / 4, A4_HEIGHT * 3 / 8) fade = Fade() photo = fade.apply_mask(infile, photo_size) photo_left = (A4_WIDTH - photo_size[0]) / 2 photo_top = 520 photo_right = photo_left + photo_size[0] photo_bottom = photo_top + photo_size[1] photo_rect = (photo_left, photo_top, photo_right, photo_bottom) page.paste(photo, photo_rect) create_title(page, (A4_WIDTH, A4_HEIGHT), photo_rect, timeid) day = tools.get_day() if not os.path.exists('png/{}'.format(day)): os.mkdir('png/{}'.format(day)) png_file = 'png/{}.jpg'.format(timeid) page.save(png_file, quality=75) tools.print_image(png_file)
def health(plan=1): infomationList = getServerinfo() #过滤服务器状态报警 dingdingAlarmDict = getAlarm.getAlarmDict(infomationList) dingdingAlarmDict.setdefault('ECSHealth', '') #收集阿里服务器到期日报警 #获取当前时间 # escAlarmTime = configRead.readConfig('aliyun', 'AlarmTime') currentTime = tools.get_hour() print(currentTime) print(escAlarmTime) if ((currentTime >= escAlarmTime[0]) and (currentTime <= escAlarmTime[1])): print('ECS报警时段命中') print('报警时段:' + escAlarmTime[0] + escAlarmTime[1]) currentDay = tools.get_day() print(currentDay) print(gl.getvalue('escSendday')) tools.recordLog('ECS报警时段命中') tools.recordLog(currentDay) tools.recordLog(gl.getvalue('escSendday')) if currentDay != gl.getvalue('escSendday'): print('ECS收集,天不同') tools.recordLog('ECS收集信息,一天只能一次') try: ecsAlarmList = alarmecs.getAlarmEcs() print(ecsAlarmList) numAlarm = len(ecsAlarmList) print('有' + str(numAlarm) + '台ECS将要到期') tools.recordLog('有' + str(numAlarm) + '台ECS将要到期') except Exception as err: tools.recordLog("alarmecs.getAlarmEcs err : " + str(err)) print(str(err)) if numAlarm > 0: print('ecs报警了') tools.recordLog('ecs>0报警了') gl.setvalue('escSendday', currentDay) dingdingAlarmDict['ECSHealth'] = '有' + str( numAlarm) + '台ECS将要到期' ecslists = ecslist.getEcslist() ecsfile = configRead.readConfig('aliyun', 'ecsfile') tools.writelisttohtml(ecslists, ecsfile) #print('打印MSG 字典') #print(dingdingAlarmDict) DingDingRobot.sendAlarm(dingdingAlarmDict, plan) tools.recordLog(str(dingdingAlarmDict)) #报警数据上色,生成html infomationList1 = htmlAlarm.color(infomationList, 0) #上色 htmlfile = configRead.readConfig('parameter', 'webfile') tools.writelisttohtml(infomationList1, htmlfile) #生成html infomationList2 = htmlAlarm.color(infomationList, 1) #上色,带升级链接 htmlfile = configRead.readConfig('parameter', 'webupdatefile') tools.writelisttohtml(infomationList2, htmlfile) #生成html getsqlServer() tools.recordLog('同步数据获取完毕') logging.debug('End of program'.center(30, '-'))