Example #1
0
        for dmp_file in glob(os.path.join(original_saved_data_path, "*.dmp")):
            filename = os.path.basename(dmp_file)
            dst = os.path.join(new_saved_data_path, filename)
            copy2(dmp_file, dst)
            os.chmod(dst, 0777)
            os.chown(dst, config.file_owner_uid, config.file_owner_gid)
    except IOError, e:
        raise Exception("Cannot copy file into %s. %s" % (dst, e))
    except OSError, e:
        raise Exception("Cannot copy file into  %s. %s" % (dst, e))

    # Restore validation files from saved_data and run validation to create all required files.
    jfile = JFileValidator(config.report_root, new_element_id, None)
    jfile.restore_validation_data()
    reportValidator = ReportValidator()
    reportValidator.init(new_element_id)
    reportValidator.report_generation()

#        print simplejson.dumps({'status': 'OK', 'message': 'report %s duplicated to %s successfully' % (original_element_id, new_element_id)})
#    except Exception, message:
#        _logger.error("Report duplication. Report %s duplication failed. Exception %s" % (original_element_id, message))
#        log_traceback(_logger, traceback)
#        print simplejson.dumps({'status':'ERROR', 'message':'report %s duplication failed. %s' % (original_element_id, message)})


def _clone_relation_data(_db, object_id, tables, table_info, select_info, update_values):
    """
    Clone relation data.
    @param object_id: root record id, for example element_id
    @param tables: list of tables to copy (order is respected)
    @param table_info: dict with table infos: pk (name of the pk) and updates (list of columns to update and where to take value)
Example #2
0
                                'chart_generation': (report.chart_generation, {'chart_id': extra_id}),
                                'restore_validation_data': (report.restore_validation_data, {}),
                                'saving_report': (report.save_validation_data, {}),
                                'save_validation_data': (report.save_validation_data, {})
                                }
            try:
                command, params = validator_commands[validator_command]
            except ValueError:
                self.unknown_command()
            #if validator_command in ['restore_validation_data', 'saving_report', 'save_validation_data']:
            if validator_command in ['restore_validation_data']:
                report.get_data = False
            else:
                report.get_data = True

            report.init(element_id)
            if command:
                fetched_rows = command(**params)
                
        except MySQLdb.Error, message:
            self._logger.error("Report validator. Try to validate element %s. SQL error %s" % (element_id, message))
            log_traceback(self._logger, traceback)
            print simplejson.dumps({'status':'ERROR', 'message':'validation failed. SQL error %s' % message, 'fetched_rows':''})
            sys.exit()
        except Exception, exc:
            self._logger.error("Report validator. Try to validate element %s. Exception %s" % (element_id, exc))
            log_traceback(self._logger, traceback)
            print simplejson.dumps({'status':'ERROR', 'message':'validation failed. %s' % exc, 'fetched_rows': ''})
            sys.exit()

        print simplejson.dumps({'status':'OK', 'message':'report validated successfully', 'fetched_rows': fetched_rows})