Exemplo n.º 1
0
 def create_html_report(self, force_write):
     contents = ''
     # Use all scripts under html/partials/
     contents += self.get_content_from('partials')
     # Use all scripts under html/summaries/
     contents += self.get_content_from('summaries')
     new_file, first_line = get_filename(HTMLREPORT, self.profile,
                                         self.report_dir)
     printInfo('Creating %s ...' % new_file)
     if prompt_4_overwrite(new_file, force_write):
         if os.path.exists(new_file):
             os.remove(new_file)
         with open(os.path.join(self.html_data_path, self.html_root)) as f:
             with open(new_file, 'wt') as nf:
                 for line in f:
                     newline = line.replace(
                         REPORT_TITLE,
                         REPORT_TITLE + ' [' + self.profile + ']')
                     if self.profile != 'default':
                         new_config_filename = AWSCONFIG_FILE.replace(
                             '.js', '-%s.js' % self.profile)
                         new_exceptions_filename = EXCEPTIONS_FILE.replace(
                             '.js', '-%s.js' % self.profile)
                         newline = newline.replace(AWSCONFIG_FILE,
                                                   new_config_filename)
                         newline = newline.replace(EXCEPTIONS_FILE,
                                                   new_exceptions_filename)
                     newline = newline.replace('<!-- PLACEHOLDER -->',
                                               contents)
                     nf.write(newline)
     return new_file
Exemplo n.º 2
0
 def load_from_file(self, config_type, config_path = None, first_line = None):
     if not config_path:
         config_path, first_line = get_filename(config_type, self.profile, self.report_dir)
     with open(config_path, 'rt') as f:
         json_payload = f.readlines()
         if first_line:
             json_payload.pop(0)
         json_payload = ''.join(json_payload)
     return json.loads(json_payload)
Exemplo n.º 3
0
Arquivo: js.py Projeto: zulcss/Scout2
 def load_from_file(self, config_type):
     config_path, first_line = get_filename(config_type, self.profile,
                                            self.report_dir)
     with open(config_path, 'rt') as f:
         json_payload = f.readlines()
         if first_line:
             json_payload.pop(0)
         json_payload = ''.join(json_payload)
     return json.loads(json_payload)
Exemplo n.º 4
0
 def save_to_file(self, config, config_type, force_write, debug):
     config_path, first_line = get_filename(config_type, self.profile, self.report_dir)
     print('Saving data to %s' % config_path)
     try:
         with self.__open_file(config_path, force_write, False) as f:
             if first_line:
                 print('%s' % first_line, file=f)
             print('%s' % json.dumps(config, indent=4 if debug else None, separators=(',', ': '), sort_keys=True, cls=Scout2Encoder), file=f)
     except Exception as e:
         printException(e)
Exemplo n.º 5
0
 def save_to_file(self, config, config_type, force_write, debug):
     config_path, first_line = get_filename(config_type, self.profile,
                                            self.report_dir)
     print('Saving data to %s' % config_path)
     try:
         with self.__open_file(config_path, force_write, False) as f:
             if first_line:
                 print('%s' % first_line, file=f)
             print('%s' % json.dumps(config,
                                     indent=4 if debug else None,
                                     separators=(',', ': '),
                                     sort_keys=True,
                                     cls=Scout2Encoder),
                   file=f)
     except Exception as e:
         printException(e)