def purge_old_birch(): print_label("Purging old BIRCH") os.chdir(ARGS.install_dir) contents = os.listdir(os.getcwd()) if "install-birch" in contents: for each in birch_files: if (each != "local" and each.count("birch_backup") != 1 and os.path.lexists(ARGS.install_dir + "/" + each)): print_console("Removing old BIRCH component: " + each) filename = ARGS.install_dir + "/" + each if (os.path.isdir(filename)): try: shutil.rmtree(filename) if (os.path.isdir(filename)): os.remove(filename) except: err = traceback.format_exc() print_console(err) JOptionPane.showMessageDialog( None, "An error occurred deleting file: " + filename) else: pass
def purge_old_birch(): print_label("Purging old BIRCH") os.chdir(ARGS.install_dir) contents=os.listdir(os.getcwd()) if "install-birch" in contents: for each in birch_files: if (each!="local" and each.count("birch_backup")!=1 and os.path.lexists(ARGS.install_dir+"/"+each)): print_console("Removing old BIRCH component: "+each) filename=ARGS.install_dir+"/"+each if (os.path.isdir(filename)): try: shutil.rmtree(filename) if (os.path.isdir(filename)): os.remove(filename) except: err=traceback.format_exc() print_console(err) JOptionPane.showMessageDialog(None, "An error occurred deleting file: "+filename) else: pass
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 update_birch(): print_label("Updating BIRCH") check_directory(ARGS.install_dir) os.chdir(ARGS.install_dir) if (ARGS.make_backup): compress_old_birch() run_nobirch() purge_old_birch() main_install() print_console("Update complete")
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()
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 if (fetch): print_label('Fetching archives') get_framework() get_binaries() #call install #main_install() else: #call update #update_birch()