def bakfile(projectfile): """A path to a valid project backup file.""" project = ProjetReader(projectfile) project.backup_project_file() project.close() assert osp.exists(projectfile + '.bak') return projectfile + '.bak'
def restore_from_backup(self, filename): """ Try to restore the project from its backup file. """ self.close_projet() msg_box = QMessageBox( QMessageBox.Warning, "Restore project warning", ("<b>Failed to restore the project.</b><br><br>" "We are very sorry for the inconvenience. " "Please submit a bug report on our GitHub issue tracker."), buttons=QMessageBox.Ok, parent=self) # First we check that the backup is ok. try: backup = ProjetReader(filename + '.bak') assert backup.check_project_file() is True backup.close() except Exception: msg_box.exec_() return False # Then we try to restore the project from the backup. print("Restoring project from backup... ", end='') try: os.remove(filename) copyfile(filename + '.bak', filename) except (OSError, PermissionError): print('failed') msg_box.exec_() return False else: print('done') return self.load_project(filename)
def projectfile(projectpath): """A path to a valid existing project file.""" project = ProjetReader(projectpath) assert osp.exists(projectpath) project.name = NAME project.author = NAME project.lat = LAT project.lon = LON project.close() return projectpath
hydrograph.language = 'english' hydrograph.fwidth = 11. # Width of the figure in inches hydrograph.fheight = 8.5 hydrograph.WLdatum = 0 # 0 -> mbgs ; 1 -> masl hydrograph.trend_line = False hydrograph.gridLines = 2 # Gridlines Style hydrograph.isGraphTitle = 1 # 1 -> title ; 0 -> no title hydrograph.isLegend = 1 hydrograph.meteo_on = True # True or False hydrograph.datemode = 'year' # 'month' or 'year' hydrograph.date_labels_pattern = 1 hydrograph.bwidth_indx = 2 # Meteo Bin Width # 0: daily | 1: weekly | 2: monthly | 3: yearly hydrograph.RAINscale = 100 hydrograph.best_fit_time(wldset.xldates) hydrograph.best_fit_waterlvl() hydrograph.generate_hydrograph() # ---- Show figure on-screen imgview = ImageViewer() imgview.sfmax = 10 imgview.load_mpl_figure(hydrograph) imgview.show() projet.close() sys.exit(app.exec_())