Example #1
0
    def get_syncano_instance(self):
        try:
            instance = self.syncano.Instance.please.get(name=config.get('P2S', 'SYNCANO_INSTANCE_NAME'))
        except:
            instance = self.syncano.Instance.please.create(name=config.get('P2S', 'SYNCANO_INSTANCE_NAME'))

        return instance
Example #2
0
    def parse(self):
        if self._parse:
            return self._parse

        parse_connection = ParseConnection(
            application_id=config.get('P2S', 'PARSE_APPLICATION_ID'),
            master_key=config.get('P2S', 'PARSE_MASTER_KEY'),
        )

        self._parse = parse_connection
        return self._parse
Example #3
0
    def syncano(self):
        if self._syncano:
            return self._syncano

        syncano_connection = syncano.connect(
            api_key=config.get('P2S', 'SYNCANO_ADMIN_API_KEY'),
            host=config.get('P2S', 'SYNCANO_APIROOT'),
            instance_name=config.get('P2S', 'SYNCANO_INSTANCE_NAME'),
        )

        self._syncano = syncano_connection
        return self._syncano
Example #4
0
def sync(namespace):
    """
    Synchronize the parse data object with syncano data objects;
    """
    check_configuration(silent=True)
    application_id = config.get('P2S', 'PARSE_APPLICATION_ID')
    instance_name = config.get('P2S', 'SYNCANO_INSTANCE_NAME')
    confirmation = raw_input('Are you sure you want to copy your data from Parse application ({application_id})'
                             ' to the Syncano Isntance ({instance_name})? Y/N [Y]: '.format(
                                 application_id=application_id,
                                 instance_name=instance_name)
                             ) or 'Y'

    if confirmation not in ['Y', 'YES', 'y', 'yes']:
        log.info('Transfer aborted.')
        return

    transfer = SyncanoTransfer()
    transfer.through_the_red_sea()
Example #5
0
def check_config_value(config_var_name, silent, section='P2S'):
    config_var = config.get(section, config_var_name)
    if not config_var:
        force_config_value(config_var_name, section)
    else:
        if not silent:
            print("{config_var_name}: \t\t{config_var}".format(
                config_var_name=config_var_name,
                config_var=config_var
            ))
Example #6
0
def print_configuration():
    for config_var_name in CONFIG_VARIABLES_NAMES:
        print("{config_var_name}: \t\t{config_var}".format(
            config_var_name=config_var_name,
            config_var=config.get('P2S', config_var_name) or "-- NOT SET --"
        ))