Beispiel #1
0
 def setup(self, migration_id=None, option_args=None):
     info = {
         'src': dict(get_config_ini('src', file='test.ini')),
         'target': dict(get_config_ini('target', file='test.ini')),
     }
     data = dict()
     if migration_id:
         data['migration_id'] = migration_id
     for _key, value in info.items():
         for data_key, data_value in value.items():
             if "[" not in data_key:
                 data[_key + '_' + data_key] = data_value
             else:
                 key_path = re.split(r"[\[\]]", data_key.strip(']'))
                 if _key + '_' + key_path[0] not in data:
                     data[_key + '_' + key_path[0]] = dict()
                 data[_key + '_' + key_path[0]][key_path[1]] = data_value
     data['test'] = True
     setup_info = self.call_server('action/setup_cart', data)
     if isinstance(setup_info, str):
         setup_info = json_decode(setup_info)
     if setup_info['result'] != 'success':
         return setup_info
     notice = setup_info['data']
     migration_data = {
         'notice': json_encode(notice),
     }
     model = LeBasecart()
     migration_data['migration_id'] = migration_id
     if not migration_id:
         migration_id = to_int(self.get_max_migration_id()) + 1
         model.set_migration_id(migration_id)
         self.call_server('action/clear_previous_data', {
             'migration_id': migration_id,
             'test': True
         })
         notice['migration_id'] = migration_id
         migration_data = {
             'notice': json_encode(notice),
         }
         migration_data['migration_id'] = migration_id
         model.get_db(test=True).set_migration_id(migration_id)
         migration = model.insert_obj(TABLE_MIGRATION,
                                      data=migration_data,
                                      insert_id=True)
         if migration['result'] != 'success':
             return response_error()
         self.set_max_migration_id(migration_id)
     else:
         migration = model.update_obj(TABLE_MIGRATION, migration_data,
                                      {'migration_id': migration_id})
         if migration['result'] != 'success':
             return response_error()
     return response_success(migration_id)
Beispiel #2
0
	def change_mode(self, migration_id, option_args):
		mode = option_args.mode
		model = LeBasecart()
		model.set_migration_id(migration_id)
		model.get_db(test = True).set_migration_id(migration_id)
		migration = model.select_row(TABLE_MIGRATION, {'migration_id': migration_id})
		if not migration:
			return
		update = dict()
		update['mode'] = MIGRATION_FULL if mode == 'full' else MIGRATION_DEMO
		notice = json_decode(migration['notice'])
		notice['mode'] = MIGRATION_FULL if mode == 'full' else MIGRATION_DEMO
		update['notice'] = json_encode(notice)
		model.update_obj(TABLE_MIGRATION, update, {'migration_id': migration_id})
		return