Esempio n. 1
0
    def _archive(self, args, temp_name):
        # Now archive the file
        with jms_utils.paths.ChDir(self.new_dir):
            if os.path.exists(temp_name + '.app'):
                log.debug('Got mac .app')
                app_name = temp_name + '.app'
                name = self.app_name
                self._mac_binary_rename(app_name, name)
            elif os.path.exists(temp_name + '.exe'):
                log.debug('Got win .exe')
                app_name = temp_name + '.exe'
                name = self.app_name
            else:
                app_name = temp_name
                name = self.app_name
            version = args.app_version
            log.debug('Temp Name: {}'.format(temp_name))
            log.debug('Appname: {}'.format(app_name))
            log.debug('Version: {}'.format(version))

            # Time for some archive creation!
            file_name = make_archive(name, app_name, version)
            log.debug('Archive name: {}'.format(file_name))
            if args.keep is False:
                if os.path.exists(temp_name):
                    log.debug('Removing: {}'.format(temp_name))
                    remove_any(temp_name)
                if os.path.exists(app_name):
                    log.debug('Removing: {}'.format(temp_name))
                    remove_any(app_name)
        log.info('{} has been placed in your new folder\n'.format(file_name))
Esempio n. 2
0
    def _overwrite_app(self):  # pragma: no cover
        # Unix: Overwrites the running applications binary
        if jms_utils.system.get_system() == 'mac':
            if self.current_app_dir.endswith('MacOS') is True:
                log.debug('Looks like we\'re dealing with a Mac Gui')
                temp_dir = get_mac_dot_app_dir(self.current_app_dir)
                self.current_app_dir = temp_dir

        app_update = os.path.join(self.update_folder, self.name)
        # Must be dealing with Mac .app application
        if not os.path.exists(app_update):
            app_update += '.app'
        log.debug('Update Location'
                  ':\n{}'.format(os.path.dirname(app_update)))
        log.debug('Update Name: {}'.format(os.path.basename(app_update)))

        current_app = os.path.join(self.current_app_dir, self.name)
        # Must be dealing with Mac .app application
        if not os.path.exists(current_app):
            current_app += '.app'
        log.debug('Current App location:\n\n{}'.format(current_app))
        # Remove current app to prevent errors when moving
        # update to new location
        if os.path.exists(current_app):
            remove_any(current_app)

        log.debug('Moving app to new location')
        shutil.move(app_update, os.path.dirname(current_app))
Esempio n. 3
0
 def test_extract_no_file(self, client):
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.download() is True
     with ChDir(update.update_folder):
         files = os.listdir(os.getcwd())
         for f in files:
             remove_any(f)
     if get_system() != 'win':
         assert update.extract() is False
Esempio n. 4
0
 def test_extract_no_file(self, client):
     update = client.update_check(client.app_name, '0.0.1')
     assert update is not None
     assert update.download() is True
     with ChDir(update.update_folder):
         files = os.listdir(os.getcwd())
         for f in files:
             remove_any(f)
     if get_system() != 'win':
         assert update.extract() is False
Esempio n. 5
0
 def _setup(self):
     # Create required directories
     self.pyi_dir = os.path.join(os.getcwd(), settings.USER_DATA_FOLDER)
     self.new_dir = os.path.join(self.pyi_dir, 'new')
     self.build_dir = os.path.join(os.getcwd(), settings.CONFIG_DATA_FOLDER)
     self.spec_dir = os.path.join(self.build_dir, 'spec')
     self.work_dir = os.path.join(self.build_dir, 'work')
     for d in [self.build_dir, self.spec_dir, self.work_dir,
               self.pyi_dir, self.new_dir]:
         if os.path.exists(self.work_dir):
             remove_any(self.work_dir)
         if not os.path.exists(d):
             log.debug('Creating directory: {}'.format(d))
             os.mkdir(d)
Esempio n. 6
0
def _clean():
    cleaned = False
    if os.path.exists(settings.CONFIG_DATA_FOLDER):
        cleaned = True
        remove_any(settings.CONFIG_DATA_FOLDER)
        log.info('Removed {} folder'.format(settings.CONFIG_DATA_FOLDER))
    if os.path.exists(settings.USER_DATA_FOLDER):
        cleaned = True
        remove_any(settings.USER_DATA_FOLDER)
        log.info('Removed {} folder'.format(settings.USER_DATA_FOLDER))
    if cleaned is True:
        log.info('Clean complete...')
    else:
        log.info('Nothing to clean...')
Esempio n. 7
0
def archive(args):
    check = check_repo()
    if check is False:
        _repo_error()
    new_dir = os.path.join(os.getcwd(), settings.USER_DATA_FOLDER, 'new')
    name = args.name
    target_name = args.target_name
    version = args.version

    with ChDir(new_dir):
        if not os.path.exists(target_name):
            log.error('{} does not exists'.format(target_name))
            return
        ex_lib = ExternalLib(name, target_name, version)
        ex_lib.archive()
        if args.keep is False:
            remove_any(target_name)
            log.info('Removed: {}'.format(target_name))