How to use restore_plugins method in Slash

Best Python code snippet using slash

setup_OpenELIS.py

Source:setup_OpenELIS.py Github

copy

Full Screen

...427 log("Backing up plugins to " + ROLLBACK_DIR + get_action_time() + PLUGIN_PATH, PRINT_TO_CONSOLE)428 shutil.copytree(TOMCAT_DIR + '/webapps/' + APP_NAME + PLUGIN_PATH, ROLLBACK_DIR + get_action_time() + '/plugin')429 else:430 log("This version of openELIS does not support plugins, can not backup", PRINT_TO_CONSOLE)431def restore_plugins():432 if os.path.isdir(ROLLBACK_DIR + get_action_time() + '/plugin/') and len(433 os.listdir(ROLLBACK_DIR + get_action_time() + '/plugin/')) > 1:434 log("Restoring " + ROLLBACK_DIR + get_action_time() + PLUGIN_PATH, PRINT_TO_CONSOLE)435 cmd = 'cp -r ' + ROLLBACK_DIR + get_action_time() + '/plugin/* ' + TOMCAT_DIR + '/webapps/' + APP_NAME + PLUGIN_PATH436 os.system(cmd)437 log("Restarting tomcat to install plugins into OpenElis", PRINT_TO_CONSOLE)438 return True439 else:440 log("No plugins to restore", PRINT_TO_CONSOLE)441 return False442def delete_war_file_from_tomcat(name):443 war_path = TOMCAT_DIR + '/webapps/' + name + '.war'444 os.remove(war_path)445def delete_app_directory_from_tomcat(name):446 cmd = 'rm -r ' + TOMCAT_DIR + '/webapps/' + name + '/'447 os.system(cmd)448def delete_work_directory_from_tomcat(name):449 cmd = 'rm -r ' + TOMCAT_DIR + '/work/Catalina/localhost/' + name + '/'450 os.system(cmd)451def delete_backup():452 if os.path.exists(BACKUP_DIR):453 log("removing backup", PRINT_TO_CONSOLE)454 shutil.rmtree(BACKUP_DIR)455 if os.path.exists(CRON_INSTALL_DIR + CRON_FILE):456 log("removing crontab", PRINT_TO_CONSOLE)457 os.remove(CRON_INSTALL_DIR + CRON_FILE)458def delete_backup_script():459 if os.path.exists(BACKUP_DIR + BACKUP_SCRIPT_NAME):460 os.remove(BACKUP_DIR + BACKUP_SCRIPT_NAME)461def do_install():462 find_installation_name()463 log("installing " + APP_NAME, PRINT_TO_CONSOLE)464 create_postgres_password()465 config_files_for_postgres()466 # prepare any site-specific information467 print APP_NAME468 if APP_NAME == 'haitiOpenElis' or APP_NAME == 'CDI_RegLabOpenElis':469 config_site_information()470 # add database users and install db471 install_db()472 # set values for tomcat473 config_files_for_tomcat()474 # run liquibase for any last minute updates475 update_with_liquibase()476 stop_tomcat()477 # copy postgres jar file478 postgres_file = glob.glob(BIN_DIR + 'postgres*')479 if TOMCAT_VERSION == "tomcat5.5":480 cmd = 'cp ' + postgres_file[0] + ' ' + TOMCAT_DIR + '/common/lib/'481 else:482 cmd = 'cp ' + postgres_file[0] + ' ' + TOMCAT_DIR + '/lib/'483 os.system(cmd)484 copy_tomcat_config_file()485 copy_war_file_to_tomcat()486 start_tomcat()487 install_backup()488 # remove the files with passwords489 staging_files = glob.glob(STAGING_DIR + '*')490 for file in staging_files:491 cmd = "rm " + file492 os.system(cmd)493def create_postgres_password():494 global CLINLIMS_PWD495 CLINLIMS_PWD = ''.join(Random().sample(string.letters, 12))496def copy_tomcat_config_file():497 cmd = 'cp ' + STAGING_DIR + APP_NAME + '.xml ' + TOMCAT_DIR + '/conf/Catalina/localhost/'498 os.system(cmd)499 if TOMCAT_VERSION == "tomcat5.5":500 cmd = 'chown tomcat55:nogroup ' + TOMCAT_DIR + '/conf/Catalina/localhost/' + APP_NAME + '.xml'501 else:502 cmd = 'chown ' + TOMCAT_VERSION + ":" + TOMCAT_VERSION + ' ' + TOMCAT_DIR + '/conf/Catalina/localhost/' + APP_NAME + '.xml'503 os.system(cmd)504def do_uninstall():505 global APP_NAME506 log("checking for current installation", PRINT_TO_CONSOLE)507 installed_name = find_installed_name()508 if len(installed_name) == 0:509 log("Unable to find installed OpenELIS in tomcat", PRINT_TO_CONSOLE)510 print "The database can **NOT** be backed up\n"511 remove_db = raw_input("Do you want to remove the database? y/n")512 if remove_db.lower() == 'y':513 log("User selected to remove database", not PRINT_TO_CONSOLE)514 delete_database()515 return516 if not find_installation_name():517 log('Unable to find name of application in installer, exiting', PRINT_TO_CONSOLE)518 return519 if not APP_NAME == installed_name:520 log('Installed name: ' + installed_name + " does not match name in installer: " + APP_NAME, PRINT_TO_CONSOLE)521 remove = raw_input("Do you want to remove " + installed_name + "? y/n")522 if not (remove.lower() == 'y'):523 return524 else:525 remove = raw_input("Do you want to remove " + APP_NAME + " from tomcat? y/n ")526 if not remove.lower() == 'y':527 return528 APP_NAME = installed_name529 stop_tomcat()530 backup_db()531 backup_war_file()532 backup_config_file()533 log("removing " + APP_NAME, PRINT_TO_CONSOLE)534 config_file = TOMCAT_DIR + '/conf/Catalina/localhost/' + APP_NAME + '.xml'535 if not os.path.isfile(config_file):536 log("unable to find config file, continuing", not PRINT_TO_CONSOLE)537 else:538 os.remove(config_file)539 delete_war_file_from_tomcat(APP_NAME)540 delete_app_directory_from_tomcat(APP_NAME)541 do_delete_backup = raw_input("Do you want to remove backupfiles from this machines y/n ")542 if do_delete_backup.lower() == 'y':543 delete_backup()544 delete_backup_script()545 delete_database()546 start_tomcat()547def delete_database():548 log("Dropping clinlims database and OpenELIS database roles", PRINT_TO_CONSOLE)549 os.system('su -c "dropdb -e clinlims" postgres')550 os.system('su -c "dropuser -e clinlims" postgres')551 os.system('su -c "dropuser -e admin" postgres')552def check_update_preconditions():553 if not check_postgres_preconditions():554 return False555 global TOMCAT_DIR556 global TOMCAT_VERSION557 TOMCAT_DIR = get_tomcat_directory()558 TOMCAT_VERSION = TOMCAT_DIR.strip(TOMCAT_INSTALL_DIR)559 # get name of existing war files560 webapps = glob.glob(TOMCAT_DIR + '/webapps/*.war')561 # get name of new war file562 find_installation_name()563 matching_war = APP_NAME + ".war"564 # return their compare value565 for file in webapps:566 if matching_war == get_file_name(file):567 return True568 return False569def find_password(app_name):570 global CLINLIMS_PWD571 config_file = open(TOMCAT_DIR + '/conf/Catalina/localhost/' + app_name + '.xml')572 for line in config_file:573 password_index = line.find("password")574 if password_index > 0:575 password_values = line[password_index:].split("\"")576 CLINLIMS_PWD = password_values[1]577 return True578def apply_separate_test_fix():579 if not os.path.exists(FIX_DIR + "collapseTests/packages/python-pgsql_2.5.1-2+b2_i386.deb"):580 log("Note: Not applying separateTestFix.", PRINT_TO_CONSOLE)581 return582 matches = glob.glob(os.path.join(APT_CACHE_DIR, "python-pgsql*"))583 # The only systems this is being applied to are those where the module has not584 # yet been installed so if it is installed it is assumed that the fix has been run already585 if len(matches) > 0:586 log("Separate Test Fix already run", PRINT_TO_CONSOLE)587 return588 log("Apply Separate Test Fix", PRINT_TO_CONSOLE)589 packages = glob.glob(FIX_DIR + "collapseTests/packages/*")590 for package in packages:591 shutil.copy(package, APT_CACHE_DIR)592 cmd = "dpkg -i " + FIX_DIR + "collapseTests/packages/*"593 os.system(cmd)594 cmd = "python " + FIX_DIR + "collapseTests/testReconfiguration_Linux.py -p " + CLINLIMS_PWD + " -d clinlims"595 os.system(cmd)596 log("Fix applied", PRINT_TO_CONSOLE)597def get_action_time():598 global ACTION_TIME599 if ACTION_TIME == '':600 ACTION_TIME = strftime("%Y_%m_%d-%H_%M_%S", time.localtime())601 cmd = 'mkdir ' + ROLLBACK_DIR + '/' + ACTION_TIME602 os.system(cmd)603 return ACTION_TIME604def backup_db():605 backup_name = get_action_time() + '/openElis.backup'606 find_password(find_installed_name())607 log("backing up database to " + ROLLBACK_DIR + backup_name, PRINT_TO_CONSOLE)608 os.system(609 "PGPASSWORD=\"" + CLINLIMS_PWD + "\";export PGPASSWORD; su -c 'pg_dump -h localhost -U clinlims clinlims > " + ROLLBACK_DIR + backup_name + "'")610def backup_config_file():611 app_name = find_installed_name()612 backup_name = get_action_time() + '/' + app_name + '.xml'613 log("Backing up configuration to " + ROLLBACK_DIR + backup_name, PRINT_TO_CONSOLE)614 cmd = 'cp ' + TOMCAT_DIR + '/conf/Catalina/localhost/' + app_name + ".xml " + ROLLBACK_DIR + backup_name615 os.system(cmd)616def do_update():617 log("Updating " + APP_NAME, PRINT_TO_CONSOLE)618 if not find_password(APP_NAME):619 log("Unable to find password from configuration file. Exiting", PRINT_TO_CONSOLE)620 return621 stop_tomcat()622 backup_db()623 backup_war_file()624 backup_config_file()625 backup_plugins()626 delete_app_directory_from_tomcat(APP_NAME)627 delete_work_directory_from_tomcat(APP_NAME)628 copy_war_file_to_tomcat()629 update_with_liquibase()630 # apply_separate_test_fix() -- no longer needed 2.4 or later631 install_backup()632 start_tomcat()633 time.sleep(10)634 if restore_plugins():635 restart_tomcat()636 log("Finished updating " + APP_NAME, PRINT_TO_CONSOLE)637def update():638 if not check_update_preconditions():639 log(APP_NAME + "is not an existing installation, can not update.\n", PRINT_TO_CONSOLE)640 webapps = glob.glob(TOMCAT_DIR + '/webapps/*.war')641 clean_exit()642 do_update()643 # check if backup exists644 if not os.path.exists(BACKUP_DIR + BACKUP_SCRIPT_NAME):645 install_backup()646def ensure_dir_exists(dir):647 if not os.path.exists(dir):648 os.mkdir(dir)...

Full Screen

Full Screen

PBBackup.py

Source:PBBackup.py Github

copy

Full Screen

1#'''2#Created on 15.07.20113#changed on 17.07.20114#@author: terrajoe5#'''6##########################################################7# -*- coding: utf-8 -*-8from __init__ import _9from Screens.Screen import Screen10from Components.MenuList import MenuList11from Components.ActionMap import ActionMap12from Screens.MessageBox import MessageBox13from Screens.Console import Console14from enigma import *15from Components.GUIComponent import GUIComponent16from Components.HTMLComponent import HTMLComponent17from Tools.Directories import fileExists18from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest19class PBBackup(Screen):20 skin = """21 <screen name="PBBackup" position="center,center" size="650,420" title="Backup / Restore Scripts" flags="wfNoBorder">22 <widget name="menu" position="45,84" size="425,300" scrollbarMode="showOnDemand" backgroundColor="black" transparent="1" />23 <eLabel text="Backup / Restore Scripts" position="20,8" size="485,50" font="Regular;32" backgroundColor="black" shadowOffset="-3,-3" shadowColor="black" transparent="1" />24 <widget source="global.CurrentTime" render="Label" position="555,20" size="90,28" font="Regular;23" halign="right" backgroundColor="black" foregroundColor="grey" shadowOffset="-2,-2" shadowColor="black" transparent="1">25 <convert type="ClockToText">Format:%d.%b</convert>26 </widget>27 <widget source="global.CurrentTime" render="Label" position="475,20" size="80,28" font="Regular;23" halign="right" backgroundColor="black" shadowOffset="-2,-2" shadowColor="black" transparent="1">28 <convert type="ClockToText">Default</convert>29 </widget>30 <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/pics/pb_small.png" position="480,200" size="150,150" backgroundColor="black" alphatest="blend" />31 </screen>"""32 def __init__(self, session, args = 0):33 self.session = session34 list = []35 list.append(SimpleEntry(_("Setup Path for Backup"), "path.png"))36 list.append(SimpleEntry("---", "div.png"))37 list.append(SimpleEntry(_("Backup Keys"), "safe.png"))38 list.append(SimpleEntry(_("Backup Settings"), "safe.png"))39 list.append(SimpleEntry(_("Backup Cams and Configs"), "safe.png"))40 list.append(SimpleEntry(_("Backup Pluginlist"), "safe.png"))41 list.append(SimpleEntry(_("Backup all"), "safe.png"))42 list.append(SimpleEntry("---", "div.png"))43 list.append(SimpleEntry(_("Restore Keys"), "restore.png"))44 list.append(SimpleEntry(_("Restore Settings"), "restore.png"))45 list.append(SimpleEntry(_("Restore Cams and Configs"), "restore.png"))46 list.append(SimpleEntry(_("Restore Pluginlist with new Plugins"), "restore.png"))47 list.append(SimpleEntry(_("Restore all"), "restore.png"))48 list.append(SimpleEntry("---", "div.png"))49 list.append(SimpleEntry(_("Delete all Backups"), "trash.png"))50 Screen.__init__(self, session)51 self['menu'] = ExtrasList(list)52 self["myActionMap"] = ActionMap(["SetupActions"],53 {54 "ok": self.go,55 "cancel": self.cancel56 }, -1)57 def go(self):58 index = self['menu'].getSelectedIndex()59 if (index == 0):60 try:61 from Plugins.Extensions.PowerboardCenter.backuppath import SetBackupPath62 except Exception, e:63 print e64 return65 self.session.open(SetBackupPath)66 elif (index == 2):67 self.session.open(Console,_("Backup Keys"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Backup_keys.sh")])68 elif (index == 3):69 self.session.open(Console,_("Backup Settings"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Backup_settings.sh")])70 elif (index == 4):71 self.session.open(Console,_("Backup Cams and Configs"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Backup_camsandconfigs.sh")])72 elif (index == 5):73 self.session.open(Console,_("Backup Pluginlist"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Backup_plugins.sh")])74 elif (index == 6):75 self.session.open(Console,_("Backup all"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Backup_all.sh")])76 elif (index == 8):77 self.session.open(Console,_("Restore Keys"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Restore_keys.sh")])78 elif (index == 9):79 self.session.open(Console,_("Restore Settings"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Restore_settings.sh")])80 elif (index == 10):81 self.session.open(Console,_("Restore Cams and Configs"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Restore_camsandconfigs.sh")])82 elif (index == 11):83 self.session.open(Console,_("Restore Pluginlist with new Plugins"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Restore_plugins.sh")])84 elif (index == 12):85 self.session.open(Console,_("Restore all"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Restore_all.sh")])86 elif (index == 14):87 self.session.open(Console,_("Delete all Backups"), cmdlist=[("/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/Scripts/Delete_all_backups.sh")])88 def cancel(self):89 print "\n[menu] cancel\n"90 self.close(None)91###########################################################################92def SimpleEntry(name, picture):93 res = [(name, picture)]94 #res = []95 picture = ('/usr/lib/enigma2/python/Plugins/Extensions/PowerboardCenter/pics/' + picture)96 if name == "---":97 if fileExists(picture):98 res.append(MultiContentEntryPixmapAlphaTest(pos=(0, 22), size=(470, 4), png=loadPNG(picture)))99 else:100 if fileExists(picture):101 res.append(MultiContentEntryPixmapAlphaTest(pos=(0, 0), size=(48, 48), png=loadPNG(picture)))102 res.append(MultiContentEntryText(pos=(60, 10), size=(450, 38), font=0, text=name))103 return res104class ExtrasList(MenuList, HTMLComponent, GUIComponent):105 def __init__(self, list, enableWrapAround = False):106 GUIComponent.__init__(self)107 self.l = eListboxPythonMultiContent()108 self.list = list109 self.l.setList(list)110 self.l.setFont(0, gFont('Regular', 21))111 self.l.setItemHeight(48)112 self.onSelectionChanged = []113 self.enableWrapAround = enableWrapAround114 self.last = 0115 GUI_WIDGET = eListbox116 def postWidgetCreate(self, instance):117 instance.setContent(self.l)118 instance.selectionChanged.get().append(self.selectionChanged)119 if self.enableWrapAround:120 self.instance.setWrapAround(True)121 def selectionChanged(self):122 isDiv = False123 try:124 for element in self.list[self.getSelectionIndex()]:125 if element[0] == "---":126 isDiv = True127 if self.getSelectionIndex() < self.last:128 self.up()129 else:130 self.down()131 except Exception, e:132 pass133 self.last = self.getSelectionIndex()134 if not isDiv:135 for f in self.onSelectionChanged:136 f()...

Full Screen

Full Screen

test_plugin_config.py

Source:test_plugin_config.py Github

copy

Full Screen

1import pytest2import slash3from slash.plugins import PluginInterface4@pytest.fixture(autouse=True)5def restore_plugins(request):6 request.addfinalizer(slash.plugins.manager.install_builtin_plugins)7 request.addfinalizer(slash.plugins.manager.uninstall_all)8def test_plugin_config():9 assert 'sample' not in slash.config['plugin_config']10 value = object()11 class Plugin(PluginInterface):12 def get_name(self):13 return 'sample'14 def get_default_config(self):15 return {16 'values': {17 'value_1': value,18 }}19 plugin = Plugin()...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Slash automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful