Exemplo n.º 1
0
def updateSyncRecordHashAndSync():
    try:
        config.logger.info("controller:updateSyncRecordHashAndSync()")
        if is_on():
            roast_record = roast.getRoast()
            sync_record, sync_record_hash = roast.getSyncRecord(roast_record)
            if is_synced():  # check if profile is under sync already
                server_updates_modified_at = sync.getApplidedServerUpdatesModifiedAt(
                )
                if server_updates_modified_at is not None and "roast_id" in roast_record:
                    sync.addSync(roast_record["roast_id"],
                                 server_updates_modified_at)
                    sync.setApplidedServerUpdatesModifiedAt(None)
                # artisan.plus is ON and the profile is under sync
                if sync.syncRecordUpdated(roast_record):
                    # we push updates on the sync record back to the server via the queue
                    queue.addRoast(sync_record)
            elif "roast_id" in roast_record and queue.full_roast_in_queue(
                    roast_record["roast_id"]):
                # in case this roast is not yet in sync cache as it has not been successfully uploaded, but a corresponding full roast
                # record is already in the uploading queue we add this updating sync_record also to the queue
                queue.addRoast(sync_record)
            return sync_record_hash
        else:
            return None
    except Exception as e:
        import sys
        _, _, exc_tb = sys.exc_info()
        config.logger.error(
            "controller: Exception in updateSyncRecordHashAndSync() line %s: %s",
            exc_tb.tb_lineno, e)
        return None
Exemplo n.º 2
0
def updateSyncRecordHashAndSync():
    try:
        config.logger.info("controller:updateSyncRecordHashAndSync()")
        if is_connected():
            roast_record = roast.getRoast()
            sync_record, sync_record_hash = roast.getSyncRecord(roast_record)
            if is_synced():
                server_updates_modified_at = sync.getApplidedServerUpdatesModifiedAt(
                )
                if server_updates_modified_at is not None and "roast_id" in roast_record:
                    sync.addSync(roast_record["roast_id"],
                                 server_updates_modified_at)
                    sync.setApplidedServerUpdatesModifiedAt(None)
                # we are connected and the profile is under sync
                if sync.syncRecordUpdated(roast_record):
                    # we push updates on the sync record back to the server
                    queue.addRoast(sync_record)
            return sync_record_hash
        else:
            return None
    except Exception as e:
        import sys
        _, _, exc_tb = sys.exc_info()
        config.logger.error(
            "controller: Exception in updateSyncRecordHashAndSync() line %s: %s",
            exc_tb.tb_lineno, e)