Esempio n. 1
0
    def job_prep(self):
        """This is a job setup function.

        The job prep will parse the payload and determine the best course of
        action
        """
        for key, val in self.pay_load:
            self.container = key
            work_q = generators.manager_queue(iters=val)
            # Prep Nova for Upload
            self.oscmd = novacommands.NovaAuth(self.args, work_q)

            if self.args.get('con_per_dir'):
                head, sep, tail = val[0].partition(key)
                self.base_path = '%s%s' % (head, sep)
            elif self.args.get('archive'):
                self.base_path = '%s%s' % (os.getenv('HOME'), os.sep)
            elif self.args.get('delete'):
                self.base_path = None
            elif self.args.get('download'):
                real_path = os.path.realpath(self.args.get('source'))
                if not os.path.isdir(real_path):
                    self.mkdir_p(real_path)
                    print('Downloaded Objects will be found here : "%s"'
                          % real_path)
                self.base_path = real_path
            elif os.path.isdir(self.args.get('source')):
                self.base_path = os.path.realpath(self.args.get('source'))
            else:
                break_down = os.path.realpath(self.args.get('source'))
                _fn = os.path.basename(break_down)
                self.base_path = break_down.strip(_fn)

            # Prep our Container
            if any([self.args.get('download'), self.args.get('delete')]):
                pass
            else:
                self.oscmd.container_create(self.container)
                if self.args.get('cdn_enabled'):
                    self.oscmd.enable_cdn(self.container)

            # If not verbose or Debug mode, show me a nice spinner
            _it = IndicatorThread(work_q=work_q)
            if not any([self.args.get('verbose'),
                        self.args.get('debug'),
                        self.args.get('os_verbose'),
                        self.args.get('quiet')]):
                thd = _it.indicator_thread()
            else:
                thd = None

            generators.worker_proc(job_action=self.run_function,
                                   multipools=self.multipools,
                                   work_q=work_q)
            if thd:
                thd.terminate()
Esempio n. 2
0
    def job_prep(self):
        """
        This is a job setup function, the job prep will parse the payload
        and determine the best course of action
        """
        for key, val in self.pay_load:
            self.container = key
            work_q = generators.manager_queue(iters=val)
            # Prep Nova for Upload
            self.oscmd = novacommands.NovaAuth(self.args, work_q)

            if self.args['con_per_dir'] or self.args['archive']:
                head, sep, tail = val[0].partition(key)
                self.base_path = '%s%s' % (head, sep)
            elif self.args['delete']:
                self.base_path = None
            elif self.args['download']:
                real_path = os.path.realpath(self.args['source'])
                if not os.path.isdir(real_path):
                    self.mkdir_p(real_path)
                    print('Downloaded Objects will be found here : "%s"'
                          % real_path)
                self.base_path = real_path
            elif os.path.isdir(self.args['source']):
                self.base_path = os.path.realpath(self.args['source'])
            else:
                break_down = os.path.realpath(self.args['source'])
                _fn = os.path.basename(break_down)
                self.base_path = break_down.strip(_fn)
            self.oscmd.connection_prep()

            # Prep our Container
            if self.args['download'] or self.args['delete']:
                pass
            else:
                self.oscmd.container_create(self.container)
                if self.args['cdn_enabled']:
                    self.oscmd.enable_cdn(self.container)

            # Thread into the job that we need to accomplish
            self.oscmd.connection_prep()
            generators.worker_proc(job_action=self.run_function,
                                   multipools=self.multipools,
                                   work_q=work_q)

            # Close the connection because I am done
            self.oscmd.connection_prep(conn_close=True)