コード例 #1
0
ファイル: sync.py プロジェクト: bopopescu/qvo-vadis
def sync_new_events(configuration, condition, don_t_run_too_long=False):
    new = fusion_tables.select(configuration['master table'],
                               condition=condition)
    logging.info(
        "Syncing %d new rows in %s master %s" %
        (len(new), configuration['id'], configuration['master table']))
    for row in new:
        # create slave dicts
        (slaves, final_date) = fusion_tables.master_to_slave(row)
        # store slave dicts
        for slave in slaves:
            fusion_tables.insert_hold(configuration['slave table'], slave)
            # set master event state to 'public'
        update = {
            'rowid': row['rowid'],
            'state': 'public',
            'sync date':
            datetime.today().strftime(FUSION_TABLE_DATE_TIME_FORMAT),
            'final date': final_date
        }
        fusion_tables.update_with_implicit_rowid(configuration['master table'],
                                                 update)
        running_too_long(don_t_run_too_long)
    fusion_tables.insert_go(configuration['slave table'])
    logging.info("Done syncing new rows in %s master %s" %
                 (configuration['id'], configuration['master table']))
コード例 #2
0
ファイル: sync.py プロジェクト: vicmortelmans/qvo-vadis
def sync_outdated_events(configuration, condition):
    outdated = fusion_tables.select(configuration['master table'], condition=condition)
    logging.info("Syncing %d outdated public rows in %s master %s" % (len(outdated), configuration['id'], configuration['master table']))
    for row in outdated:
        # select old slave rows
        condition = "'event slug' = '%s'" % row['event slug']
        slaves = fusion_tables.select(configuration['slave table'], cols=['datetime slug'], condition=condition, filter_obsolete_rows=False)
        # create slave dicts
        datetime_slugs = [slave['datetime slug'] for slave in slaves]
        (new_slaves, final_date) = fusion_tables.master_to_slave(row)
        # store slave dicts
        logging.info("Inserting approx. %d future rows in %s slave %s" % (len(new_slaves) - len(slaves), configuration['id'], configuration['slave table']))
        for new_slave in new_slaves:
            if new_slave['datetime slug'] not in datetime_slugs:
                fusion_tables.insert_hold(configuration['slave table'], new_slave)
            # set master event state to 'public'
        update = {
            'rowid': row['rowid'],
            'state': 'public',
            'sync date': datetime.today().strftime(FUSION_TABLE_DATE_TIME_FORMAT),
            'final date': final_date
        }
        logging.info("Updated sync timestamp and final date in regenerated row in %s master %s" % (configuration['id'], configuration['master table']))
        fusion_tables.update_with_implicit_rowid(configuration['master table'], update)
        running_too_long(don_t_run_too_long=True)
    fusion_tables.insert_go(configuration['slave table'])
    logging.info("Done syncing outdated public rows in %s master %s" % (configuration['id'], configuration['master table']))
コード例 #3
0
ファイル: sync.py プロジェクト: vicmortelmans/qvo-vadis
def sync_updated_events(configuration, condition, don_t_run_too_long=False):
    updated = fusion_tables.select(configuration['master table'], condition=condition)
    logging.info("Syncing %d updated rows in %s master %s" % (len(updated), configuration['id'], configuration['master table']))
    for row in updated:
        # old rows are not deleted! New slave rows are just added with incremented sequence number
        # create slave dicts
        (slaves, final_date) = fusion_tables.master_to_slave(row)
        # store slave dicts
        for slave in slaves:
            fusion_tables.insert_hold(configuration['slave table'], slave)
        # delete the old master row (the updated row was a copy!)
        condition = "'event slug' = '%s' and 'state' = 'public'" % row['event slug']
        old = fusion_tables.select(configuration['master table'], cols=['rowid'], condition=condition)
        for old_row in old:  # should be only a single row!!
            fusion_tables.delete_with_implicit_rowid(configuration['master table'], old_row)
        # set master event state to 'public'
        update = {
            'rowid': row['rowid'],
            'state': 'public',
            'sync date': datetime.today().strftime(FUSION_TABLE_DATE_TIME_FORMAT),
            'final date': final_date
        }
        fusion_tables.update_with_implicit_rowid(configuration['master table'], update)
        running_too_long(don_t_run_too_long)
    fusion_tables.insert_go(configuration['slave table'])
    logging.info("Done syncing updated rows in %s master %s" % (configuration['id'], configuration['master table']))
コード例 #4
0
ファイル: sync.py プロジェクト: bopopescu/qvo-vadis
    def get(self):
        configuration = customer_configuration.get_configuration(self.request)
        count = self.request.get('count')
        for i in xrange(0, int(count)):
            master = fusion_tables.random_master(configuration)
            fusion_tables.insert_hold(configuration['master table'], master)
        fusion_tables.insert_go(configuration['master table'])

        # return the web-page content
        self.response.out.write("LoadHandler finished")
        return
コード例 #5
0
ファイル: sync.py プロジェクト: vicmortelmans/qvo-vadis
    def get(self):
        configuration = customer_configuration.get_configuration(self.request)
        count = self.request.get('count')
        for i in xrange(0, int(count)):
            master = fusion_tables.random_master(configuration)
            fusion_tables.insert_hold(configuration['master table'], master)
        fusion_tables.insert_go(configuration['master table'])

        # return the web-page content
        self.response.out.write("LoadHandler finished")
        return
コード例 #6
0
ファイル: sync.py プロジェクト: vicmortelmans/qvo-vadis
def sync_new_events(configuration, condition, don_t_run_too_long=False):
    new = fusion_tables.select(configuration['master table'], condition=condition)
    logging.info("Syncing %d new rows in %s master %s" % (len(new), configuration['id'], configuration['master table']))
    for row in new:
        # create slave dicts
        (slaves, final_date) = fusion_tables.master_to_slave(row)
        # store slave dicts
        for slave in slaves:
            fusion_tables.insert_hold(configuration['slave table'], slave)
            # set master event state to 'public'
        update = {
            'rowid': row['rowid'],
            'state': 'public',
            'sync date': datetime.today().strftime(FUSION_TABLE_DATE_TIME_FORMAT),
            'final date': final_date
        }
        fusion_tables.update_with_implicit_rowid(configuration['master table'], update)
        running_too_long(don_t_run_too_long)
    fusion_tables.insert_go(configuration['slave table'])
    logging.info("Done syncing new rows in %s master %s" % (configuration['id'], configuration['master table']))
コード例 #7
0
ファイル: sync.py プロジェクト: bopopescu/qvo-vadis
def sync_outdated_events(configuration, condition):
    outdated = fusion_tables.select(configuration['master table'],
                                    condition=condition)
    logging.info(
        "Syncing %d outdated public rows in %s master %s" %
        (len(outdated), configuration['id'], configuration['master table']))
    for row in outdated:
        # select old slave rows
        condition = "'event slug' = '%s'" % row['event slug']
        slaves = fusion_tables.select(configuration['slave table'],
                                      cols=['datetime slug'],
                                      condition=condition,
                                      filter_obsolete_rows=False)
        # create slave dicts
        datetime_slugs = [slave['datetime slug'] for slave in slaves]
        (new_slaves, final_date) = fusion_tables.master_to_slave(row)
        # store slave dicts
        logging.info("Inserting approx. %d future rows in %s slave %s" %
                     (len(new_slaves) - len(slaves), configuration['id'],
                      configuration['slave table']))
        for new_slave in new_slaves:
            if new_slave['datetime slug'] not in datetime_slugs:
                fusion_tables.insert_hold(configuration['slave table'],
                                          new_slave)
            # set master event state to 'public'
        update = {
            'rowid': row['rowid'],
            'state': 'public',
            'sync date':
            datetime.today().strftime(FUSION_TABLE_DATE_TIME_FORMAT),
            'final date': final_date
        }
        logging.info(
            "Updated sync timestamp and final date in regenerated row in %s master %s"
            % (configuration['id'], configuration['master table']))
        fusion_tables.update_with_implicit_rowid(configuration['master table'],
                                                 update)
        running_too_long(don_t_run_too_long=True)
    fusion_tables.insert_go(configuration['slave table'])
    logging.info("Done syncing outdated public rows in %s master %s" %
                 (configuration['id'], configuration['master table']))
コード例 #8
0
ファイル: sync.py プロジェクト: bopopescu/qvo-vadis
def sync_updated_events(configuration, condition, don_t_run_too_long=False):
    updated = fusion_tables.select(configuration['master table'],
                                   condition=condition)
    logging.info(
        "Syncing %d updated rows in %s master %s" %
        (len(updated), configuration['id'], configuration['master table']))
    for row in updated:
        # old rows are not deleted! New slave rows are just added with incremented sequence number
        # create slave dicts
        (slaves, final_date) = fusion_tables.master_to_slave(row)
        # store slave dicts
        for slave in slaves:
            fusion_tables.insert_hold(configuration['slave table'], slave)
        # delete the old master row (the updated row was a copy!)
        condition = "'event slug' = '%s' and 'state' = 'public'" % row[
            'event slug']
        old = fusion_tables.select(configuration['master table'],
                                   cols=['rowid'],
                                   condition=condition)
        for old_row in old:  # should be only a single row!!
            fusion_tables.delete_with_implicit_rowid(
                configuration['master table'], old_row)
        # set master event state to 'public'
        update = {
            'rowid': row['rowid'],
            'state': 'public',
            'sync date':
            datetime.today().strftime(FUSION_TABLE_DATE_TIME_FORMAT),
            'final date': final_date
        }
        fusion_tables.update_with_implicit_rowid(configuration['master table'],
                                                 update)
        running_too_long(don_t_run_too_long)
    fusion_tables.insert_go(configuration['slave table'])
    logging.info("Done syncing updated rows in %s master %s" %
                 (configuration['id'], configuration['master table']))