Example #1
0
 def get_command(self):
     try:
         if os.name == 'nt':
             lessc = misc.find_in_path('lessc.cmd')
         else:
             lessc = misc.find_in_path('lessc')
     except IOError:
         lessc = 'lessc'
     lesspath = get_resource_path('web', 'static', 'lib', 'bootstrap', 'less')
     return [lessc, '-', '--no-js', '--no-color', '--include-path=%s' % lesspath]
Example #2
0
 def get_command(self):
     try:
         if os.name == 'nt':
             lessc = misc.find_in_path('lessc.cmd')
         else:
             lessc = misc.find_in_path('lessc')
     except IOError:
         lessc = 'lessc'
     lesspath = get_resource_path('web', 'static', 'lib', 'bootstrap', 'less')
     return [lessc, '-', '--no-js', '--no-color', '--include-path=%s' % lesspath]
Example #3
0
 def _get_lo_bin(self):
     lo_bin = self.env['ir.config_parameter'].sudo().get_param(
         AEROO_CONVERSION_COMMAND_PARAMETER,
         'soffice',
     )
     try:
         lo_bin = find_in_path(lo_bin)
     except IOError:
         lo_bin = None
     if not lo_bin:
         try:
             lo_bin = find_in_path('libreoffice')
         except IOError:
             lo_bin = None
     return lo_bin
Example #4
0
def _find_lpr_exec():
    """Find usable lpr executable"""
    try:
        lpr_exec = find_in_path('lpr')
        return lpr_exec
    except IOError:
        raise UserError(_("Cannot find lpr executable"))
 def _convert_pdf(self, temp_pdf_file):
     """
     Converts pdf to ensure the import is capable of reading pdf
     :param temp_pdf_file: File object
     :return: converted pdf data
     """
     temp_pdf_file.seek(0)
     gs = find_in_path('gs')
     args = [
         '-sDEVICE=pdfwrite', '-dCompatibilityLevel=1.4',
         '-dPDFSETTINGS=/screen', '-dNOPAUSE', '-dQUIET', '-dBATCH'
     ]
     with NamedTemporaryFile() as output:
         command = [gs] + args + [
             '-sOutputFile=' + output.name, temp_pdf_file.name
         ]
         process = subprocess.Popen(command,
                                    stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
         process.communicate()
         if process.returncode not in [0, 1]:
             # Convert failed, we return original pdf
             return temp_pdf_file.read()
         output.seek(0)
         return output.read()
Example #6
0
 def get_command(self):
     try:
         sass = misc.find_in_path('sass')
     except IOError:
         sass = 'sass'
     return [sass, '--stdin', '-t', 'compressed', '--unix-newlines', '--compass',
             '-r', 'bootstrap-sass']
Example #7
0
    def dump_pgbadger(self, dir_dump, output, cursor):
        pgbadger = find_in_path("pgbadger")
        if not pgbadger:
            _logger.error("Pgbadger not found")
            return
        filename = os.path.join(dir_dump, output)
        pg_version = dump_db_manifest(cursor)['pg_version']
        log_path = os.environ.get('PG_LOG_PATH', DFTL_LOG_PATH % pg_version)
        if not os.path.exists(os.path.dirname(filename)):
            try:
                os.makedirs(os.path.dirname(filename))
            except OSError as exc:
                # error is different than File exists
                if exc.errno != errno.EEXIST:
                    _logger.error("File can be created")
                    return
        _logger.info("Generating PG Badger report.")
        exclude_query = self.get_exclude_query()
        dbname = cursor.dbname
        command = [
            pgbadger, '-f', 'stderr', '-T', 'Odoo-Profiler', '-o', '-', '-d',
            dbname, '-b', ProfilerController.begin_date, '-e',
            ProfilerController.end_date, '--sample', '2', '--disable-type',
            '--disable-error', '--disable-hourly', '--disable-session',
            '--disable-connection', '--disable-temporary', '--quiet'
        ]
        command.extend(exclude_query)
        command.append(log_path)

        _logger.info("Pgbadger Command:")
        _logger.info(command)
        result = tools.exec_command_pipe(*command)
        with open(filename, 'w') as fw:
            fw.write(result[1].read())
        _logger.info("Done")
Example #8
0
 def get_command(self):
     try:
         sass = misc.find_in_path('sass')
     except IOError:
         sass = 'sass'
     return [sass, '--stdin', '-t', 'compressed', '--unix-newlines', '--compass',
             '-r', 'bootstrap-sass']
 def _get_lo_bin(self):
     lo_bin = (self.env["ir.config_parameter"].sudo().get_param(
         PY3O_CONVERSION_COMMAND_PARAMETER, "libreoffice"))
     try:
         lo_bin = find_in_path(lo_bin)
     except IOError:
         lo_bin = None
     return lo_bin
Example #10
0
 def get_command(self):
     try:
         sassc = misc.find_in_path('sassc')
     except IOError:
         sassc = 'sassc'
     return [
         sassc, '--stdin', '--precision',
         str(self.precision), '--load-path', self.bootstrap_path, '-t',
         self.output_style
     ]
Example #11
0
    def run_rtlcss(self, source):
        rtlcss = 'rtlcss'
        if os.name == 'nt':
            try:
                rtlcss = misc.find_in_path('rtlcss.cmd')
            except IOError:
                rtlcss = 'rtlcss'
        cmd = [rtlcss, '-']

        try:
            rtlcss = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        except Exception:

            # Check the presence of rtlcss, if rtlcss not available then we should return normal less file
            try:
                process = Popen(['rtlcss', '--version'],
                                stdout=PIPE,
                                stderr=PIPE)
            except (OSError, IOError):
                _logger.warning(
                    'You need https://rtlcss.com/ to convert css file to right to left compatiblity. Use: npm install -g rtlcss'
                )
                return source

            msg = "Could not execute command %r" % cmd[0]
            _logger.error(msg)
            self.css_errors.append(msg)
            return ''

        result = rtlcss.communicate(input=source.encode('utf-8'))
        if rtlcss.returncode:
            cmd_output = ''.join(misc.ustr(result))
            if not cmd_output:
                cmd_output = "Process exited with return code %d\n" % rtlcss.returncode
            error = self.get_rtlcss_error(cmd_output, source=source)
            _logger.warning(error)
            self.css_errors.append(error)
            return ''
        rtlcss_result = result[0].strip().decode('utf8')
        return rtlcss_result
Example #12
0
    def run_rtlcss(self, source):
        rtlcss = 'rtlcss'
        if os.name == 'nt':
            try:
                rtlcss = misc.find_in_path('rtlcss.cmd')
            except IOError:
                rtlcss = 'rtlcss'
        cmd = [rtlcss, '-']


        try:
            rtlcss = Popen(cmd, stdin=PIPE, stdout=PIPE, stderr=PIPE)
        except Exception:

            # Check the presence of rtlcss, if rtlcss not available then we should return normal less file
            try:
                process = Popen(
                    ['rtlcss', '--version'], stdout=PIPE, stderr=PIPE
                )
            except (OSError, IOError):
                _logger.warning('You need https://rtlcss.com/ to convert css file to right to left compatiblity. Use: npm install -g rtlcss')
                return source

            msg = "Could not execute command %r" % cmd[0]
            _logger.error(msg)
            self.css_errors.append(msg)
            return ''

        result = rtlcss.communicate(input=source.encode('utf-8'))
        if rtlcss.returncode:
            cmd_output = ''.join(misc.ustr(result))
            if not cmd_output:
                cmd_output = "Process exited with return code %d\n" % rtlcss.returncode
            error = self.get_rtlcss_error(cmd_output, source=source)
            _logger.warning(error)
            self.css_errors.append(error)
            return ''
        rtlcss_result = result[0].strip().decode('utf8')
        return rtlcss_result
 def _convert_pdf(self, temp_pdf_file):
     """
     Converts pdf to ensure the import is capable of reading pdf
     :param temp_pdf_file: File object
     :return: converted pdf data
     """
     temp_pdf_file.seek(0)
     gs = find_in_path('gs')
     args = ['-sDEVICE=pdfwrite', '-dCompatibilityLevel=1.4',
             '-dPDFSETTINGS=/screen', '-dNOPAUSE', '-dQUIET', '-dBATCH']
     with NamedTemporaryFile() as output:
         command = [gs] + args + [
             '-sOutputFile=' + output.name,
             temp_pdf_file.name
         ]
         process = subprocess.Popen(command, stdout=subprocess.PIPE,
                                    stderr=subprocess.PIPE)
         process.communicate()
         if process.returncode not in [0, 1]:
             # Convert failed, we return original pdf
             return temp_pdf_file.read()
         output.seek(0)
         return output.read()
Example #14
0
def _get_wkhtmltopdf_bin():
    wkhtmltopdf_bin = find_in_path('wkhtmltopdf')
    if wkhtmltopdf_bin is None:
        raise IOError
    return wkhtmltopdf_bin
Example #15
0
def _get_wkhtmltopdf_bin():
    return find_in_path('wkhtmltopdf')
Example #16
0
def get_command(format_out, file_convert):
    try:
        unoconv = find_in_path('unoconv')
    except IOError:
        unoconv = 'unoconv'
    return [unoconv, "--stdout", "-f", "%s" % format_out, "%s" % file_convert]
Example #17
0
 def get_command(self):
     try:
         sassc = misc.find_in_path('sassc')
     except IOError:
         sassc = 'sassc'
     return [sassc, '--stdin', '--precision', str(self.precision), '--load-path', self.bootstrap_path, '--load-path', self.bootstrap_components_path, '-t', self.output_style]
Example #18
0
def _get_wkhtmltopdf_bin():
    return find_in_path('wkhtmltopdf')