FLAGS.AddFlag('d', 'database', 'The database to use', 'gallery2') FLAGS.AddFlag('h', 'hostname', 'The hostname to use', 'localhost') FLAGS.AddFlag('t', 'table_prefix', 'The table prefix to use', 'g2_') FLAGS.AddFlag('f', 'field_prefix', 'The field prefix to use', 'g_') def main(argv): appname = argv[0] try: argv = FLAGS.Parse(argv[1:]) except flags.FlagParseError, e: utils.Usage(appname, e.usage(), e.message()) sys.exit(1) gdb = db.Database(FLAGS.username, FLAGS.password, FLAGS.database, FLAGS.hostname, FLAGS.table_prefix, FLAGS.field_prefix) try: albums = [] album_ids = gdb.ItemIdsForTable(items.AlbumItem.TABLE_NAME) for id in album_ids: albums.append(items.AlbumItem(gdb, id)) photos_by_album = {} photo_ids = gdb.ItemIdsForTable(items.PhotoItem.TABLE_NAME) for id in photo_ids: photo = items.PhotoItem(gdb, id) if photo.parent_id() not in photos_by_album: photos_by_album[photo.parent_id()] = [] photos_by_album[photo.parent_id()].append(photo)
return ret_val # Override the HTTP exception handler. app.handle_http_exception = get_http_exception_handler(app) api = Api(app, prefix='/api/v1') app.config['UPLOAD_FOLDER'] = g.config['images_path'] app.config['MAX_CONTENT_LENGTH'] = g.MAX_FILE_SIZE_MB * 1024 * 1024 app.config['JWT_SECRET_KEY'] = g.config['mlapi_secret_key'] app.config['JWT_ACCESS_TOKEN_EXPIRES'] = g.ACCESS_TOKEN_EXPIRES app.config['PROPAGATE_EXCEPTIONS'] = True app.debug = False jwt = JWTManager(app) db = Database.Database() api.add_resource(Login, '/login') api.add_resource(Detect, '/detect/object') api.add_resource(Health, '/health') secrets_conf = pyzmutils.read_config(g.config['secrets']) api_options = { 'apiurl': pyzmutils.get(key='ZM_API_PORTAL', section='secrets', conf=secrets_conf), 'portalurl':pyzmutils.get(key='ZM_PORTAL', section='secrets', conf=secrets_conf), 'user': pyzmutils.get(key='ZM_USER', section='secrets', conf=secrets_conf), 'password': pyzmutils.get(key='ZM_PASSWORD', section='secrets', conf=secrets_conf), 'disable_ssl_cert_check':False if g.config['allow_self_signed']=='no' else True }
ap.add_argument('-u', '--user', help='username to create') ap.add_argument('-p', '--password', help='password of user') ap.add_argument('-d', '--dbpath', default='./db', help='path to DB') ap.add_argument('-f', '--force', help='force overwrite user', action='store_true') ap.add_argument('-l', '--list', help='list all users', action='store_true') ap.add_argument('-r', '--remove', help='remove user') args, u = ap.parse_known_args() args = vars(args) g.config['db_path'] = args.get('dbpath') db = Database.Database(prompt_to_create=False) if args.get('list'): print('----- Configured users ---------------') for i in db.get_all_users(): print('User: {}'.format(i.get('name'))) exit(0) if args.get('remove'): u = args.get('remove') if not db.get_user(u): print('User: {} not found'.format(u)) else: db.delete_user(args.get('remove')) print('OK') exit(0)
def main(argv): appname = argv[0] try: argv = FLAGS.Parse(argv[1:]) except flags.FlagParseError, e: utils.Usage(appname, e.usage(), e.message()) sys.exit(1) if FLAGS.dbpass == '': FLAGS.dbpass = getpass.getpass('DB Password:'******'': FLAGS.password = getpass.getpass('Google Password:'******'client_secrets.json' credential_store = 'credentials.dat' if FLAGS.dry_run != 'true': # pws.ClientLogin(FLAGS.username, FLAGS.password) pws = OAuth2Login(client_secrets, credential_store, FLAGS.username) confirm = FLAGS.confirm if confirm == 'true': confirm = True else: confirm = False try: