def check_directory(path): if (os.path.lexists(path)): contents = os.listdir(path) if (contents.count("install-birch") == 0): print_console("The selected directory " + path + " does NOT contain a BIRCH installation!") message = "The selected path does NOT contain a BIRCH installation.\nPlease select the base directory of the installation that you wish to update,\nOr click \"no\" to cancel update." reload = JOptionPane.showConfirmDialog(None, message, "Input", JOptionPane.YES_NO_OPTION) if (reload == JOptionPane.NO_OPTION): print_console("User aborted install.") commonlib.shutdown() fc = JFileChooser() fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY) fc.showOpenDialog(None) path = fc.getSelectedFile().getPath() check_directory(path) else: ARGS.install_dir = path print_console("The selected directory " + path + " contains a BIRCH installation, it will be updated")
def run_main(cwd): print_label("Running getbirch installer process") if (ARGS.is_update): print_console("Updating an existing BIRCH installation") ARGS.set_installdir(cwd) if "winxp-32" in ARGS.platform: print_console("This is a windows install") has_depends=True else: has_depends=check_depends() if (not has_depends): print_console("A required dependancy is not present on system path, BIRCH cannot be installed") shutdown() if (not ARGS.is_update): clobber_check() if (os.path.lexists(ARGS.install_dir)): os.chdir(ARGS.install_dir) fetch = True if (ARGS.disc_install): disc_prepare() fetch = False
def main(cwd): try: start = time.time() run_main(cwd) #this will produce a crash: must be called as module end = time.time() elapsed= end - start min = elapsed/60 print_console("Installation took "+str(min)+" minutes.") JOptionPane.showMessageDialog(None,"Please bookmark BIRCH custom documentation, which will appear in a web browser") showCustomDoc() JOptionPane.showMessageDialog(None,"Installation completed successfully.") except: # print_console(err) err=traceback.format_exc() print_console(err) #print_console("Sending bug to bugmail") #ARGS.log_file.flush() #ARGS.log_file.close() #from bugmail import send_bug #send_bug() JOptionPane.showMessageDialog(None,"Installation failed, please try again and submit install log as a bug report.") finally: print_console("Installation finished") shutdown()
def compress_old_birch(): print_label("Archiving old BIRCH") filename = "birch_backup" + str(datetime.datetime.now()).replace( " ", "") + ".tar" filename = filename.replace(":", "") filename = filename.replace("-", "") print_console("Saving old BIRCH in " + filename) tar = tarfile.open(filename, "w") os.chdir(ARGS.install_dir) for each in birch_files: if (os.path.lexists(ARGS.install_dir + "/" + each)): print_console("Archiving old birch directory " + each) try: tar.add(each) except IOError: print_console("Could not add file: \"" + each + "\" to archive:") ioerr = traceback.format_exc() print_console(str(ioerr)) message = "An IO error occurred, the file \"" + each + "\"could not be added to the archive, do you still wish to proceed?" cont = JOptionPane.showConfirmDialog(None, message, "Input", JOptionPane.YES_NO_OPTION) if (cont == JOptionPane.NO_OPTION): print_console("User aborted installation") JOptionPane.showMessageDialog( "It is recommended that you archive manually archive your previous BIRCH installation before you proceed with the update." ) commonlib.shutdown() except: err = traceback.format_exc() print_console(err) print_console( "Unhandled exception occurred, this is a bug. For safety reasons, the update has been aborted" ) JOptionPane.showMessageDialog( None, "Unhandled exception occurred, this is a bug. For safety reasons, the update has been aborted" ) commonlib.shutdown() tar.close()
def compress_old_birch(): print_label("Archiving old BIRCH") filename="birch_backup"+str(datetime.datetime.now()).replace(" ","")+".tar" filename=filename.replace(":","") filename=filename.replace("-","") print_console("Saving old BIRCH in "+filename) tar = tarfile.open(filename, "w") os.chdir(ARGS.install_dir) for each in birch_files: if (os.path.lexists(ARGS.install_dir+"/"+each)): print_console("Archiving old birch directory "+ each) try: tar.add(each) except IOError: print_console("Could not add file: \""+each+"\" to archive:") ioerr=traceback.format_exc() print_console(str(ioerr)) message="An IO error occurred, the file \""+each+"\"could not be added to the archive, do you still wish to proceed?" cont=JOptionPane.showConfirmDialog(None,message, "Input",JOptionPane.YES_NO_OPTION); if (cont==JOptionPane.NO_OPTION): print_console("User aborted installation") JOptionPane.showMessageDialog("It is recommended that you archive manually archive your previous BIRCH installation before you proceed with the update.") commonlib.shutdown() except: err=traceback.format_exc() print_console(err) print_console("Unhandled exception occurred, this is a bug. For safety reasons, the update has been aborted") JOptionPane.showMessageDialog(None,"Unhandled exception occurred, this is a bug. For safety reasons, the update has been aborted") commonlib.shutdown() tar.close()
def check_directory(path): if (os.path.lexists(path)): contents=os.listdir(path) if (contents.count("install-birch")==0): print_console("The selected directory "+path+" does NOT contain a BIRCH installation!") message="The selected path does NOT contain a BIRCH installation.\nPlease select the base directory of the installation that you wish to update,\nOr click \"no\" to cancel update." reload = JOptionPane.showConfirmDialog(None,message, "Input",JOptionPane.YES_NO_OPTION); if (reload==JOptionPane.NO_OPTION): print_console("User aborted install.") commonlib.shutdown() fc = JFileChooser(); fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fc.showOpenDialog(None); path = fc.getSelectedFile().getPath(); check_directory(path) else: ARGS.install_dir=path print_console("The selected directory "+path+" contains a BIRCH installation, it will be updated")