Esempio n. 1
0
def toggle(app_window):
    config.logger.info("controller:toggle()")
    config.app_window = app_window
    modifiers = QApplication.keyboardModifiers()
    if modifiers == (Qt.AltModifier | Qt.ControlModifier):
        # ALT+CTR-CLICK (OPTION+COMMAND on macOS) toggles the plus debug logging
        util.debugLogToggle()
    elif modifiers == Qt.AltModifier:
        # ALT-click (OPTION on macOS) sends the log file by email
        util.sendLog()
    else:
        if config.app_window.plus_account is None:  # @UndefinedVariable
            connect()
            if is_connected() and is_synced(
            ) and config.app_window.curFile is not None:  # @UndefinedVariable
                sync.sync()
        else:
            if config.connected:
                if is_synced():
                    # a CTR-click (COMMAND on macOS) logs out and discards the credentials
                    disconnect(
                        interactive=True,
                        remove_credentials=(modifiers == Qt.ControlModifier),
                        keepON=False)
                else:
                    # we (manually) turn syncing for the current roast on
                    if app_window.qmc.checkSaved(allow_discard=False):
                        queue.addRoast()
            else:
                disconnect(remove_credentials=False,
                           stop_queue=True,
                           interactive=True,
                           keepON=False)
Esempio n. 2
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
Esempio n. 3
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)
Esempio n. 4
0
def toggle(app_window):
    config.logger.info("controller:toggle()")
    config.app_window = app_window
    if config.app_window.plus_account is None: # @UndefinedVariable
        connect()
        if is_connected() and is_synced() and config.app_window.curFile is not None: # @UndefinedVariable
            sync.sync()         
    else:
        if config.connected:
            if is_synced():
                disconnect()
            else:
                # we (manually) turn syncing for the current roast on
                if app_window.qmc.checkSaved():
                    queue.addRoast()
        else:
            connect(True) # we try to re-connect and disconnect on failure
Esempio n. 5
0
def toggle(app_window):
    config.logger.info("controller:toggle()")
    config.app_window = app_window
    modifiers = QApplication.keyboardModifiers()
    if modifiers == Qt.ControlModifier:
        # send log file by email
        util.sendLog()
    else:
        if config.app_window.plus_account is None:  # @UndefinedVariable
            connect()
            if is_connected() and is_synced(
            ) and config.app_window.curFile is not None:  # @UndefinedVariable
                sync.sync()
        else:
            if config.connected:
                if is_synced():
                    disconnect(interactive=True)
                else:
                    # we (manually) turn syncing for the current roast on
                    if app_window.qmc.checkSaved(allow_discard=False):
                        queue.addRoast()
            else:
                connect(True)  # we try to re-connect and disconnect on failure