Esempio n. 1
0
def _app_make_result(result):
    r = cycle(result)
    return {
       'app_id': r.next(),
       'app_key': r.next(),
       'app_secret': r.next(),
       'app_name': from_utf8(r.next()),
       'support_android': get_support(r.next()),
       'support_ios': get_support(r.next()),
       'support_playstore': get_support(r.next()),
       'support_appstore': get_support(r.next()),
       'support_gameflier': get_support(r.next()),
       'playstore_url': r.next(),
       'appstore_url': r.next(),
       'gameflier_url': r.next(),
       'gcm_sender_id': r.next(),
       'gcm_server_api_key': r.next(),
       'gcm_config_path': r.next(),
       'facebook_app_name': r.next(),
       'facebook_app_id': r.next(),
       'facebook_app_secret': r.next(),
       'facebook_api_version': r.next(),
       'status': _app_status(r.next()),
       'reg_date': r.next(),
    }
Esempio n. 2
0
def _member_make_result(result):
    r = cycle(result)
    return {
       'app_id': r.next(),
       'member_id': r.next(),
       'udid': r.next(),
       'device_platform': _device_platform(r.next()),
       'service_platform': _service_platform(r.next()),
       'push_notification': get_support(r.next()),
       'gcm_token': r.next(),
       'facebook_id': _facebook_id(r.next()),
       'facebook_email': r.next(),
       'status': _member_status(r.next()),
       'reg_date': r.next(),
       'last_device_platform': _device_platform(r.next()),
       'last_service_platform': _service_platform(r.next()),
       'last_login_date': r.next(),
    }
Esempio n. 3
0
def load_app(force=False):
    if app.APP_NAME and force == False: return
    # load app
    con, cur = sqlrelay_cursor()
    cur.execute("""
SELECT
   app_key
 , app_secret
 , app_name
 , support_android
 , support_ios
 , support_playstore
 , support_appstore
 , support_gameflier
 , playstore_url
 , appstore_url
 , gameflier_url
 , gcm_sender_id
 , gcm_server_api_key
 , facebook_app_id
 , facebook_app_name
 , facebook_app_secret
 , facebook_api_version
 , status 
FROM
   ms_app 
WHERE
   app_id = %d
""" % (app.APP_ID))
    result = cur.fetchone()
    assert result

    r = cycle(result)
    # validate APP_KEY and APP_SECRET
    assert app.APP_KEY == r.next()
    assert app.APP_SECRET == r.next()
    app.APP_NAME = r.next()

    # validate information by support option
    app.SUPPORT_ANDROID = get_support(r.next())
    app.SUPPORT_IOS = get_support(r.next())
    app.SUPPORT_PLAYSTORE = get_support(r.next())
    app.SUPPORT_APPSTORE = get_support(r.next())
    app.SUPPORT_GAMEFLIER = get_support(r.next())
    app.PLAYSTORE_URL = r.next()
    app.APPSTORE_URL = r.next()
    app.GAMEFLIER_URL = r.next()
    app.GCM_SENDER_ID = r.next()
    app.GCM_SERVER_API_KEY = r.next()
    app.FACEBOOK_APP_ID = r.next()
    app.FACEBOOK_APP_NAME = r.next()
    app.FACEBOOK_APP_SECRET = r.next()
    app.FACEBOOK_API_VERSION = r.next()

    # load product
    cur.execute("""
SELECT
   product_id
 , product_name
 , product_price
 , inapp_id
 , service_platform
 , currency 
FROM 
   ms_app_product 
WHERE
   app_id = %d AND status = %d 
ORDER BY
   service_platform
""" % (app.APP_ID, membership_pb2.PRODUCT_STATUS_ENABLE))
    results = cur.fetchall()
    sqlrelay_close(cur, con)

    products = {
      membership_pb2.SERVICE_PLATFORM_PLAYSTORE: [],
      membership_pb2.SERVICE_PLATFORM_APPSTORE: [],
      membership_pb2.SERVICE_PLATFORM_GAMEFLIER: [],
    }
    for r in results:
        product_id = r[0]
        product_name = r[1]
        product_price = r[2]
        inapp_id = r[3]
        service_platform = int(r[4])
        currency = int(r[5])
        products[service_platform].append({
           'product_id': product_id,
           'product_name': product_name,
           'product_price': product_price,
           'inapp_id': inapp_id,
           'currency': currency,
        })

    logger.info(products)
    app.PRODUCTS = products