Пример #1
0
    def run(self):
        """Run script."""
        config = self.get_config()
        args = self.get_parser()

        if args.log:
            self.create_logger()

        self.logger.debug('-' * 10)

        # Set some vars
        self.input_dir = os.path.join(config.get('html5', 'input')).rstrip('/')
        self.user = config.get('upload', 'user')
        self.ip = config.get('upload', 'ip')
        self.remote_dir = config.get('upload', 'remote_dir')
        self.url = config.get('upload', 'url')
        self.exclude_list = self.create_list(config.get('upload', 'exclude_list'))

        # Do the stuff we came here to do
        # Check if the input dir exists
        if not os.path.isdir(self.input_dir):
            logmsg.error('"{0}" does nots exist'.format(self.input_dir))
            sys.exit()

        # Upload preview files
        self.upload()

        # Get links
        links = self.get_links()
        logmsg.success('%s ads uploaded' % len(links), self.logger)

        # Ask question
        if args.browser and logmsg.confirm('Open all ads in browser'):
            for l in links:
                webbrowser.open(l)
Пример #2
0
    def image_optim(self, files):
        """Optimize images using ImageOptim GUI. Very time intensive."""
        logmsg.header('Running ImageOptim GUI on all images...', self.logger)
        logmsg.debug('Unable to provide progress for the GUI app. This can take a while...')
        timer = Timer().start()
        # start_time = time.time()

        cmd = '/Applications/ImageOptim.app/Contents/MacOS/ImageOptim %s' % (' '.join(files))
        # print(cmd)

        proc = Popen(shlex.split(cmd), stdout=PIPE, stderr=PIPE)
        stdout, stderr = proc.communicate()
        status = not bool(proc.returncode)
        if status:
            # end_time = time.time()
            # logmsg.success('Time Elapsed: {0}'.format(end_time - start_time))
            logmsg.success('Optimized {0} images (Time Elapsed: {1})'.format(len(files), timer.stop().elapsed()))
        else:
            logmsg.error(stderr.strip())
Пример #3
0
    def run(self):
        """Run script."""
        config = self.get_config()
        args = self.get_parser()

        if args.log:
            self.create_logger()

        self.logger.debug('-' * 10)

        self.input_dir = config.get('html5', 'input')

        # Check if the input dir exists
        if not os.path.isdir(self.input_dir):
            logmsg.error('"{0}" does not exist'.format(self.input_dir))
            sys.exit()

        # Do the stuff we came here to do
        timer = Timer().start()


        logmsg.success('HTML Generated (Elapsed time: %s)' % timer.stop().elapsed())