Exemplo n.º 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)

        self.input_dir = config.get('html5', 'input')
        self.images_dir = config.get('css', 'images_dir')
        self.style_dir = config.get('css', 'style_dir')
        self.ignore_list = self.create_list(config.get('css', 'exclude_list'))

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

        for d in dirs:
            # TODO: Trim needs work...screws up our pngs
            # self.trim_pngs(d)
            self.generate_css(d)

        logmsg.success('CSS Generated (Elapsed time: %s)' % timer.stop().elapsed())
Exemplo n.º 2
0
    def upload(self):
        """Upload HTML5 ads files."""
        logmsg.header('Uploading HTML5 ad files...', self.logger)

        timer = Timer().start()

        exclude = self.create_rsync_exclude()
        cmd = 'rsync -avzhP{exclude} "{from_dir}" {user}@{ip}:{to_dir}'.format(
            exclude=exclude,
            from_dir=self.input_dir,
            user=self.user,
            ip=self.ip,
            to_dir=self.remote_dir)
        self.logger.debug(cmd)
        proc = Popen(shlex.split(cmd), stdout=PIPE, stderr=PIPE)
        stdout, stderr = proc.communicate()
        status = not bool(proc.returncode)
        if status:
            logmsg.success('Uploaded HTML ad files (Time Elapsed: {0})'.format(
                timer.stop().elapsed()), self.logger)
Exemplo n.º 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())
Exemplo n.º 4
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())