def file_move(self, event): global check_dir global save_dir global file_list global move_list file_list = [] move_list = wx.StaticText(self.panel, label='', pos=(260, 30)) verify_db.file_move(check_dir, save_dir, file_list) print file_list fl = str(file_list) fl1 = fl.replace("[", "\n") fl2 = fl1.replace("u'", '') fl3 = fl2.replace(', ', '\n') fl4 = fl3.replace("]", '\n') fl5 = fl4.replace("'", '') print fl5 move_list.SetLabel(fl5) move_box_title.SetLabel('These files were moved:') move_date = [] db_check.viewLastMove(move_date) print move_date move_date = ''.join(move_date) move_date = time.ctime((float(move_date))) print move_date save_last.SetLabel('Last Moved: '+ move_date)
def file_move(check_dir, save_dir, file_list): global move_date action_date = calendar.timegm(time.gmtime()) modWindow = action_date - 86400 print 'The current time is: ' print time.ctime(action_date) move_date = [] db_check.viewLastMove(move_date) print move_date _dir = check_dir _tran = save_dir _files = os.listdir(_dir) print '\nThe current files in folder ' + _dir + ' are:' for f in _files: print f print '\nThe dates of the files are: ' for a in _files: b = os.path.abspath(_dir + '/' + a) modified = time.ctime(os.path.getmtime(b)) created = time.ctime(os.path.getctime(b)) print '\n' + b + ' was:' print "last modified: %s" % modified print "created: %s" % created c = os.path.getmtime(b) g = os.path.getctime(b) if (c > modWindow) or (g > modWindow) or (c > move_date) or (g > move_date): print a + ' will be moved' shutil.move(b, _tran) file_list.append(a) print '' db_check.newEntry(action_date, 'Move') return file_list, action_date
def __init__(self, title): global check_dir global check_loc global check_last global save_dir global save_loc global save_last global file_list global move_box_title global move_list global action_date global move_date check_dir = os.getcwd() save_dir = os.getcwd() file_list = [] action_date = [] move_date = [] verify_db.db_initialize() db_check.viewLastCheck(action_date) db_check.viewLastMove(move_date) action_date = ''.join(action_date) action_date = time.ctime((float(action_date))) print action_date move_date = ''.join(move_date) move_date = time.ctime((float(move_date))) print move_date wx.Frame.__init__(self, None, wx.ID_ANY, title=title, size=(640, 480)) self.panel = wx.Panel(self, wx.ID_ANY) menuBar = wx.MenuBar() fileMenu = wx.Menu() menuBar.Append(fileMenu, "&File") move_box_title = wx.StaticBox(self.panel, label='Select folders to check:', pos=(250, 10), size = (300, 220)) move_list = wx.StaticText(self.panel, label='', pos=(260, 30)) wx.StaticBox(self.panel, label='Location to be checked:', pos=(10, 280), size=(605, 50)) check_loc = wx.StaticText(self.panel, label=check_dir, pos=(50, 300)) chkDirButton = wx.Button(self.panel, label="...", pos=(20, 300), size=(20, 20)) chkDirButton.Bind (wx.EVT_BUTTON, self.chkDir) wx.StaticBox(self.panel, label='Location to be save copies:', pos=(10,340), size=(605,50)) save_loc = wx.StaticText(self.panel, label=save_dir, pos=(50, 360)) savDirButton = wx.Button(self.panel, label="...", pos=(20, 360), size=(20, 20)) savDirButton.Bind (wx.EVT_BUTTON, self.savDir) button = wx.Button(self.panel, label="Check now", pos=(40,40), size=(100,40)) button.Bind (wx.EVT_BUTTON, self.file_check) check_last = wx.StaticText(self.panel, label='Last Checked: '+ action_date , pos=(20, 100)) button = wx.Button(self.panel, label="Move now", pos=(40,140), size=(100,40)) button.Bind (wx.EVT_BUTTON, self.file_move) save_last = wx.StaticText(self.panel, label='Last Moved: '+ move_date, pos=(20, 200)) button = wx.Button(self.panel, label="Exit", size=(40,40), pos=(575,10)) button.Bind (wx.EVT_BUTTON, self.exit) exitItem = fileMenu.Append(wx.NewId(), "E&xit", "Exit the program") self.Bind(wx.EVT_MENU, self.exit, exitItem) self.SetMenuBar(menuBar) self.CreateStatusBar()