Ejemplo n.º 1
0
def install(opts, conf):
    dotfiles = conf.get_dotfiles(opts['profile'])
    if dotfiles == []:
        LOG.err('no dotfiles defined for this profile (\"%s\")' %
                (str(opts['profile'])))
        return False
    t = Templategen(base=opts['dotpath'])
    inst = Installer(create=opts['create'],
                     backup=opts['backup'],
                     dry=opts['dry'],
                     safe=opts['safe'],
                     base=opts['dotpath'],
                     diff=opts['installdiff'],
                     quiet=opts['quiet'])
    installed = []
    for dotfile in dotfiles:
        if hasattr(dotfile, 'link') and dotfile.link:
            r = inst.link(dotfile.src, dotfile.dst)
        else:
            r = inst.install(t, opts['profile'], dotfile.src, dotfile.dst)
        if len(r) > 0 and len(dotfile.actions) > 0:
            # execute action
            for action in dotfile.actions:
                action.execute()
        installed.extend(r)
    LOG.log('\n%u dotfile(s) installed.' % (len(installed)))
    return True
Ejemplo n.º 2
0
    def install_agent(self, package_path):
        checksum = utils.get_checksum(package_path, self.get_checksum_dir())
        if not utils.check_file(package_path, checksum):
            LOG.debug("check downloaded package failed, removing %s",
                      package_path)
            os.remove(package_path)
            utils.remove_checksum(package_path, self.get_checksum_dir())
            return None

        dirname = utils.get_file_name_without_extension(package_path)
        agent_dir = '%s/%s' % (self.get_install_dir(), dirname)

        r = os.system('mkdir -p %s && tar xzf %s -C %s --strip-components 1' %
                      (agent_dir, package_path, agent_dir)) != 0
        if r != 0:
            LOG.debug('decompress failed, %d', r)
            os.remove(package_path)
            os.rmdir(agent_dir)
            return None
        else:
            LOG.debug('decompress success')

        installer = Installer(agent_dir, self.recycle_queue)
        installer.install()
        return agent_dir
Ejemplo n.º 3
0
    def install(self, params):
        installer = None
        installer = Installer(self.install_config, self.maxy, self.maxx,
                              self.iso_installer, self.rpm_path, self.log_path,
                              self.log_level)

        return installer.install(params)
Ejemplo n.º 4
0
    def __init__(self, buildout, name, options):
        self.log = logging.getLogger(name)
        self.egg = zc.recipe.egg.Egg(buildout, options['recipe'], options)

        self.buildout, self.name, self.options = buildout, name, options
        options['location'] = os.path.join(
            buildout['buildout']['parts-directory'], name)
        options['bin-directory'] = buildout['buildout']['bin-directory']

        options.setdefault('project', 'example.com')
        options.setdefault('external-apps', 'apps')
        options.setdefault('local-apps', 'company')
        options.setdefault('settings', 'development')
        options.setdefault('libs-path', 'lib')
        options.setdefault('script-dir', 'bin')
        options.setdefault('turboengine', '')
        options.setdefault('webservices', 'false')
        options.setdefault('zipped', 'false')

        # Usefull when using archived versions
        buildout['buildout'].setdefault(
            'download-cache',
            os.path.join(buildout['buildout']['directory'], 'downloads'))

        self.__installer = Installer(self.options, self.buildout, self.log,
                                     self.name)
Ejemplo n.º 5
0
    def install_agent(self, package_path):
        checksum = utils.get_checksum(package_path, self.get_checksum_dir())
        if not utils.check_file(package_path, checksum):
            LOG.debug("check downloaded package failed, removing %s", package_path)
            os.remove(package_path)
            utils.remove_checksum(package_path, self.get_checksum_dir())
            return None

        dirname = utils.get_file_name_without_extension(package_path)
        agent_dir = '%s\%s' % (self.get_install_dir(), dirname)
        tmp_dir = '%s\%s' % (self.get_tmp_dir(), dirname)

        try:
            if utils.unzip(package_path, tmp_dir):
                tmp_name = os.listdir(tmp_dir)[0]
                tmp_path = '%s\%s' % (tmp_dir, tmp_name)
                ren_path = '%s\%s' % (tmp_dir, dirname)

                if os.system('ren "%s" "%s"' % (tmp_path, dirname)) != 0:
                    return None

                if os.system('move "%s" "%s"' % (ren_path, self.get_install_dir())) != 0:
                    return None
            else:
                return None
        finally:
            if os.path.isdir(tmp_dir):
                os.system('rd /s /q "%s"' % tmp_dir)

        installer = Installer(agent_dir, self.recycle_queue)
        installer.install()
        return agent_dir
Ejemplo n.º 6
0
 def uninstall_agent(self, agent_dir=None):
     if self.installer is None:
         if agent_dir and os.path.isdir(agent_dir):
             self.installer = Installer(agent_dir)
         else:
             return
     self.installer.uninstall()
Ejemplo n.º 7
0
def runInstaller(options, config):
    try:
        sys.path.insert(0, options.installer_path)
        from installer import Installer
        from packageselector import PackageSelector
    except:
        raise ImportError('Installer path incorrect!')
    config["pkg_to_rpm_map_file"] = options.pkg_to_rpm_map_file
    
    # Check the installation type
    option_list_json = Utils.jsonread(options.package_list_file)
    options_sorted = option_list_json.items()

    packages = []
    if 'type' in config:
        for install_option in options_sorted:
            if install_option[0] == config['type']:
                packages = PackageSelector.get_packages_to_install(install_option[1]['packagelist_file'],
                                                               options.generated_data_path)
                break
    else:
        if 'packagelist_file' in config:
            packages = PackageSelector.get_packages_to_install(config['packagelist_file'],
                                                               options.generated_data_path)
        if 'additional_packages' in config:
            packages = packages.extend(config['additional_packages'])

    config['packages'] = packages
    # Run the installer
    package_installer = Installer(config, rpm_path=options.rpm_path,
                                  log_path=options.log_path, log_level=options.log_level)
    return package_installer.install(None)
Ejemplo n.º 8
0
 def __init__(self):
     # Init related objects
     self.app = App(self)
     self.installer = Installer(self)
     self.local_op = LocalOperations()
     self.remote_op = RemoteOperations(self)
     self.printer = Printer()
     self.connect()
     self.setup()
Ejemplo n.º 9
0
    def install(self, params):
        installer = None
        if self.install_config['type'] == "ostree_host":
            installer = OstreeInstaller(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path)
        elif self.install_config['type'] == "ostree_server":
            installer = OstreeServerInstaller(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path)
        else:
            installer = Installer(self.install_config, self.maxy, self.maxx, self.iso_installer, self.rpm_path, self.log_path)

        return installer.install(params)
Ejemplo n.º 10
0
 def uninstall_agent(self, agent_dir=None):
     # if self.installer is None:
     #     if agent_dir and os.path.isdir(agent_dir):
     #         self.installer = Installer(agent_dir, self.recycle_queue)
     #     else:
     #         return
     # self.installer.uninstall()
     # self.installer = None
     if agent_dir and os.path.isdir(agent_dir):
         installer = Installer(agent_dir, self.recycle_queue)
         installer.uninstall()
Ejemplo n.º 11
0
def runInstaller(options, install_config, working_directory):
    try:
        sys.path.insert(0, options.installer_path)
        from installer import Installer
    except:
        raise ImportError('Installer path incorrect!')

    # Run the installer
    installer = Installer(working_directory=working_directory, rpm_path=options.rpm_path,
                          log_path=options.log_path)
    installer.configure(install_config)
    installer.execute()
Ejemplo n.º 12
0
def compare(opts, conf, tmp):
    dotfiles = conf.get_dotfiles(opts['profile'])
    if dotfiles == []:
        LOG.err('no dotfiles defined for this profile (\"%s\")' %
                (str(opts['profile'])))
        return False
    t = Templategen(base=opts['dotpath'])
    inst = Installer(create=opts['create'], backup=opts['backup'],
                     dry=opts['dry'], base=opts['dotpath'], quiet=True)
    for dotfile in dotfiles:
        LOG.log('diffing \"%s\" VS \"%s\"' % (dotfile.key, dotfile.dst))
        inst.compare(t, tmp, opts['profile'], dotfile.src, dotfile.dst)
    return len(dotfiles) > 0
Ejemplo n.º 13
0
    def __init__(self):
        self.config = Config()
        self.setTempFolder()
        self.setTempFile()  # should be after setTempFolder

        self.compatibility = Compatibility()
        self.versionManager = VersionManager()
        self.md5sum = MD5sum()
        self.installer = Installer(self)
        self.initFTP()  # should be after installer
        self.initLogger()

        self.gui = PaWGui(self)
Ejemplo n.º 14
0
    def install(self):
        installer = None

        if self.install_config.get('type', '') == "ostree_host":
            installer = OstreeInstaller(self.install_config, self.maxy,
                                        self.maxx, self.iso_installer,
                                        self.rpm_path, self.log_path,
                                        self.log_level)
        else:
            installer = Installer(self.install_config, self.maxy, self.maxx,
                                  self.iso_installer, self.rpm_path,
                                  self.log_path, self.log_level)

        return installer.install()
Ejemplo n.º 15
0
 def __init__(self, ip, port, username, password, pub_key_auth, tools):
     # Setup params
     self._ip = ip
     self._port = port
     self._username = username
     self._password = password
     self._pub_key_auth = bool(pub_key_auth)
     self._tools_local = tools
     # Init related objects
     self.app = App(self)
     self.installer = Installer(self)
     self.local_op = LocalOperations()
     self.remote_op = RemoteOperations(self)
     self.printer = Printer()
Ejemplo n.º 16
0
    def __init__(self, options):
        install_config=None
        self.media_mount_path = None
        photon_media = None
        ks_path = options.install_config_file
        # Path to RPMS repository: local media or remote URL
        # If --repo-path= provided - use it,
        # if not provided - use kernel repo= parameter,
        # if not provided - use /RPMS path from photon_media,
        # exit otherwise.
        repo_path = options.repo_path

        with open('/proc/cmdline', 'r') as f:
            kernel_params = shlex.split(f.read().replace('\n', ''))

        for arg in kernel_params:
            if arg.startswith("ks="):
                if not ks_path:
                    ks_path = arg[len("ks="):]
            elif arg.startswith("repo="):
                if not repo_path:
                    repo_path = arg[len("repo="):]
            elif arg.startswith("photon.media="):
                photon_media = arg[len("photon.media="):]

        if photon_media:
            self.mount_media(photon_media)

        if not repo_path:
            if self.media_mount_path:
                repo_path = self.media_mount_path + "/RPMS"
            else:
                print("Please specify RPM repo path.")
                return

        if ks_path:
            install_config=self._load_ks_config(ks_path)

        if options.ui_config_file:
            ui_config = (JsonWrapper(options.ui_config_file)).read()
        else:
            ui_config={}
        ui_config['options_file'] = options.options_file

        # Run installer
        installer = Installer(rpm_path=repo_path, log_path="/var/log")

        installer.configure(install_config, ui_config)
        installer.execute()
Ejemplo n.º 17
0
 def create_db(self) -> None:
     """Create database, collect data and insert them."""
     print("creating tables...")
     Base.metadata.create_all(self.engine)
     print("tables created")
     print("uploading data from api...")
     collector = Collector()
     data = collector.collect()
     cleaner = Cleaner()
     data_cleaned = cleaner.cleaner(data)
     print("upload successful")
     print("adding data to tables...")
     installer = Installer()
     installer.install(data_cleaned, self.engine)
     print("database install with success")
Ejemplo n.º 18
0
def install(upgrade: bool = False, version: str = typer.Argument(None)):
    """安装Graia,--upgrade 升级Graia,可指定版本"""

    installer = Installer()
    if upgrade:
        if 0 != installer.upgrade():
            logging.error(u'升级失败')
            sys.exit(1)
        logging.info(u'升级成功')

    else:
        if 0 != installer.install(version=version):
            logging.error(u'安装失败')
            sys.exit(1)
        logging.info(u'安装成功')
Ejemplo n.º 19
0
    def install_agent(self, package_path):
        dirname = utils.get_file_name_without_extension(package_path)
        agent_dir = '%s/%s' % (self.get_install_dir(), dirname)

        r = os.system('mkdir -p %s && tar xzf %s -C %s --strip-components 1' % (agent_dir, package_path, agent_dir)) != 0
        if r != 0:
            LOG.debug('decompress failed, %d', r)
            os.remove(package_path)
            os.rmdir(agent_dir)
            return None
        else:
            LOG.debug('decompress success')

        self.installer = Installer(agent_dir)
        self.installer.install()
        return agent_dir
Ejemplo n.º 20
0
    def __init__(self, options):
        install_config = None
        self.cd_mount_path = None
        cd_search = None
        ks_path = options.install_config_file
        repo_path = options.repo_path

        with open('/proc/cmdline', 'r') as f:
            kernel_params = shlex.split(f.read().replace('\n', ''))

        for arg in kernel_params:
            if arg.startswith("ks="):
                if not ks_path:
                    ks_path = arg[len("ks="):]
            elif arg.startswith("repo="):
                if not repo_path:
                    repo_path = arg[len("repo="):]
            elif arg.startswith("photon.media="):
                cd_search = arg[len("photon.media="):]

        if not repo_path:
            print("Please specify RPM repo path.")
            return

        if cd_search:
            self.mount_cd(cd_search)

        if ks_path:
            install_config = self._load_ks_config(ks_path)

        if options.ui_config_file:
            ui_config = (JsonWrapper(options.ui_config_file)).read()
        else:
            ui_config = {}
        ui_config['options_file'] = options.options_file

        # Run installer
        installer = Installer(rpm_path=repo_path, log_path="/var/log")

        installer.configure(install_config, ui_config)
        installer.execute()
Ejemplo n.º 21
0
    def __init__(self, interface, log=False):
        """
        Arguments:
            interface {string} -- name of interface to handle
            log {object} -- object of logger (default: {False})

        Raises:
            FileNotFoundError -- raised when arptables not installed
        """
        self.log = log
        if log is False:
            from logger import Logger
            self.log = Logger()
        self.interface = interface
        installer = Installer()
        if not os.path.isfile('/usr/bin/arptables') and not os.path.isfile('/sbin/arptables'):  # Detect if arptables installed
            print(avalon.FM.BD + avalon.FG.R + '\nWe have detected that you don\'t have arptables installed!' + avalon.FM.RST)
            print('SCUTUM requires arptables to run')
            if not installer.sysInstallPackage("arptables"):
                avalon.error("arptables is required for scutum. Exiting...")
                raise FileNotFoundError("File: \"/usr/bin/arptables\" and \"/sbin/arptables\" not found")
Ejemplo n.º 22
0
 def onOK(self, event):
     parent = self.GetParent()
     i = self.box.GetSelection()
     ext = ""
     
     if i == 0:
         ext = "zip"
     elif i == 1:
         ext = "dwa"
     elif i == 2:
         ext = "mova"
     elif i == 3:
         ext = "tmx"
     elif i == 4:
         ext == "dz"
     
     from installer import Installer
     installer = Installer(parent, parent.app.config)
     installer.install(self.filePath, ext)
     
     self.Destroy()
Ejemplo n.º 23
0
def compare(opts, conf, tmp, focus=None):
    dotfiles = conf.get_dotfiles(opts['profile'])
    if dotfiles == []:
        LOG.err('no dotfiles defined for this profile (\"%s\")' %
                (str(opts['profile'])))
        return False
    t = Templategen(base=opts['dotpath'])
    inst = Installer(create=opts['create'],
                     backup=opts['backup'],
                     dry=opts['dry'],
                     base=opts['dotpath'],
                     quiet=opts['quiet'])

    # compare only specific files
    selected = dotfiles
    if focus:
        selected = []
        for selection in focus.replace(' ', '').split(','):
            df = next((x for x in dotfiles if x.dst == selection), None)
            if df:
                selected.append(df)
            else:
                LOG.err('no dotfile matches \"%s\"' % (selection))

    for dotfile in selected:
        same, diff = inst.compare(t, tmp, opts['profile'], dotfile.src,
                                  dotfile.dst)
        if same:
            if not opts['quiet']:
                LOG.log('diffing \"%s\" VS \"%s\"' %
                        (dotfile.key, dotfile.dst))
                LOG.raw('same file')
        else:
            LOG.log('diffing \"%s\" VS \"%s\"' % (dotfile.key, dotfile.dst))
            LOG.emph(diff)

    return len(selected) > 0
Ejemplo n.º 24
0
    def __init__(self, adapter, log):
        """
        Arguments:
            adapter {string} -- name of adapter to handle
            log {object} -- object of logger (default: {False})

        Raises:
            FileNotFoundError -- raised when arptables not installed
        """
        self.gateway_mac = False
        self.interface = adapter
        installer = Installer()
        if not os.path.isfile('/usr/bin/arptables') and not os.path.isfile(
                '/sbin/arptables'):  # Detect if arptables installed
            print(
                avalon.FM.BD + avalon.FG.R +
                '\nWe have detected that you don\'t have arptables installed!'
                + avalon.FM.RST)
            print('SCUTUM requires arptables to run')
            if not installer.sysInstallPackage('arptables'):
                avalon.error('arptables is required for scutum. Exiting...')
                raise FileNotFoundError(
                    'File: \"/usr/bin/arptables\" and \"/sbin/arptables\" not found'
                )
Ejemplo n.º 25
0
            "This will remove everything under {0}. Are you sure?".format(
                options.working_directory))
        if not proceed:
            sys.exit(0)

    if (os.path.isdir(options.working_directory)):
        process = subprocess.Popen(['rm', '-rf', options.working_directory])
        retval = process.wait()
    else:
        process = subprocess.Popen(['mkdir', '-p', options.working_directory])
        retval = process.wait()

    config['working_directory'] = options.working_directory

    # Run the installer
    package_installer = Installer(
        config, local_install=not (options.iso_path or options.vmdk_path))
    package_installer.install(None)

    # Making the iso if needed
    if config['iso_system']:
        process = subprocess.Popen([
            './mk-install-iso.sh', '-w', options.working_directory,
            options.iso_path, options.tools_path
        ])
        retval = process.wait()

    # Cleaning up for vmdk
    if 'vmdk_install' in config and config['vmdk_install']:
        process = subprocess.Popen(
            ['./mk-clean-vmdk.sh', config['disk']['disk']])
        process.wait()
Ejemplo n.º 26
0
    def __init__(self, args):
        self.__dict__.update(args)
        self.start_time = time.time()

        # setup some additional variables
        if self.database_host == None: self.database_host = self.client_host

        self.result_directory = os.path.join("results", self.name)

        if self.parse != None:
            self.timestamp = self.parse
        else:
            self.timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime())

        # Setup the concurrency levels array. This array goes from
        # starting_concurrency to max concurrency, doubling each time
        self.concurrency_levels = []
        concurrency = self.starting_concurrency
        while concurrency <= self.max_concurrency:
            self.concurrency_levels.append(concurrency)
            concurrency = concurrency * 2

        # Setup query interval array
        # starts at 1, and goes up to max_queries, using the query_interval
        self.query_intervals = []
        queries = 1
        while queries <= self.max_queries:
            self.query_intervals.append(queries)
            if queries == 1:
                queries = 0

            queries = queries + self.query_interval

        # Load the latest data
        self.latest = None
        try:
            with open('latest.json', 'r') as f:
                # Load json file into config object
                self.latest = json.load(f)
        except IOError:
            pass

        self.results = None
        try:
            if self.latest != None and self.name in self.latest.keys():
                with open(
                        os.path.join(self.result_directory,
                                     str(self.latest[self.name]),
                                     'results.json'), 'r') as f:
                    # Load json file into config object
                    self.results = json.load(f)
        except IOError:
            pass

        if self.results == None:
            self.results = dict()
            self.results['concurrencyLevels'] = self.concurrency_levels
            self.results['queryIntervals'] = self.query_intervals
            self.results['frameworks'] = [
                t.name for t in self.__gather_tests()
            ]
            self.results['rawData'] = dict()
            self.results['rawData']['json'] = dict()
            self.results['rawData']['db'] = dict()
            self.results['rawData']['query'] = dict()
            self.results['weighttpData'] = dict()
            self.results['weighttpData']['json'] = dict()
            self.results['weighttpData']['db'] = dict()
            self.results['weighttpData']['query'] = dict()
        else:
            for x in self.__gather_tests():
                if x.name not in self.results['frameworks']:
                    self.results['frameworks'] = self.results['frameworks'] + [
                        x.name
                    ]

        # Setup the ssh command string
        self.ssh_string = "ssh -T -o StrictHostKeyChecking=no " + self.client_user + "@" + self.client_host
        if self.identity_file != None:
            self.ssh_string = self.ssh_string + " -i " + self.identity_file

        if self.install_software:
            install = Installer(self)
            install.install_software()
Ejemplo n.º 27
0
        if (os.path.isdir(options.working_directory)):
            process = subprocess.Popen(
                ['rm', '-rf', options.working_directory])
            retval = process.wait()

        process = subprocess.Popen([
            'mkdir', '-p',
            os.path.join(options.working_directory, "photon-chroot")
        ])
        retval = process.wait()

        config['working_directory'] = options.working_directory

        # Run the installer
        package_installer = Installer(config,
                                      rpm_path=options.rpm_path,
                                      log_path=options.log_path)
        package_installer.install(None)

        # Making the iso if needed
        if options.iso_path:
            rpm_list = " ".join(
                create_rpm_list_to_be_copied_to_iso(
                    options.pkg_to_rpm_map_file,
                    options.pkg_to_be_copied_conf_file, 3,
                    options.output_data_path))
            files_to_copy = " ".join(
                create_additional_file_list_to_copy_in_iso(
                    os.path.abspath(options.stage_path),
                    options.package_list_file))
            live_cd = get_live_cd_status_string(options.package_list_file)
Ejemplo n.º 28
0

if not (args.enable or args.disable):
    printIcon()

if args.version:  # prints program legal / dev / version info
    print("Current Version: " + VERSION)
    print("Author: K4YT3X")
    print("License: GNU GPL v3")
    print("Github Page: https://github.com/K4YT3X/SCUTUM")
    print("Contact: [email protected]")
    print()
    exit(0)

log = Logger(LOGPATH)
installer = Installer(CONFPATH)

if args.upgrade:
    installer.check_avalon()
    installer.check_version(VERSION)
    exit(0)

try:
    if os.getuid() != 0:  # Arptables requires root
        avalon.error('SCUTUM must be run as root!')
        print(avalon.FG.LGR + 'It needs to control the system firewall so..' + avalon.FM.RST)
        exit(0)
    if not (args.purgelog or args.install or args.uninstall):
        # if program is doing normal operations, log everything
        # pointless if purging log, installing/removing
        log.writeLog(str(datetime.datetime.now()) + ' ---- START ----')
Ejemplo n.º 29
0
from installer import Installer

install_dir = r'E:\Tutorial\Python\steam_workshop_downloader\test\testing'
craft_id_file = r'E:\Tutorial\Python\steam_workshop_downloader\crafts.txt'

installer = Installer(install_dir)

with open(craft_id_file, 'r') as crafts:
    for craft_id in crafts:
        print(f'getting {craft_id}')
        installer.install(craft_id.strip())
    print('Done')
Ejemplo n.º 30
0
# launch setup
if is_configured() is True:
    app_ready = True
else:
    app_ready = False

# app_ready = False

if app_ready:
    from gui.main import Base, determine_version

    logging.config.dictConfig(DEV_LOGGING)
    logger = logging.getLogger("babel")

    local_version = determine_version(os.getcwd())
    app = Base()
    s = Style()
    s.theme_use("xpnative")
    s.configure(".", font=("device", 12))
    app.iconbitmap("./icons/babel2.ico")
    app.title("Babel v.{}".format(local_version))
    app.mainloop()
else:
    app = Installer()
    s = Style()
    s.theme_use("xpnative")
    s.configure(".", font=("device", 12))
    app.iconbitmap("./icons/babel2.ico")
    app.title("Babel Setup")
    app.mainloop()