Esempio n. 1
0
def fetchAppList(server):
    """Retrieves the list of ACTIVE (Locked or Unlocked) apps from VAMS.

    Returns:
        List of app info on active apps.
    """

    # Calculate request hash
    url = '%s%s' % (_DEFAULT_HOST, _APPLIST_ENDPOINT)
    print url
    date = vams.createDateString()

    req_hash = vams.calcAuthHash(_APPLIST_ENDPOINT, 'GET', date)
    print req_hash

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)

    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }
    response = requests.get(url, headers=headers)
    json_obj = json.loads(response.text)
    print json_obj
def fetchAppList(server):
    """Retrieves the list of ACTIVE (Locked or Unlocked) apps from VAMS.

    Returns:
        List of app info on active apps.
    """
    # dictionary of Victorious_App_ID [Apple_ID]
    d = {}
    # Calculate request hash
    url = '%s%s' % ('https://api.getvictorious.com', _APPLIST_ENDPOINT)
    date = vams.createDateString()
    req_hash = vams.calcAuthHash(_APPLIST_ENDPOINT, 'GET', date)

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)

    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }
    response = requests.get(url, headers=headers)
    json_obj = response.json()
    error_code = json_obj['error']

    if error_code == 0:
        app_count = 0
    payload = json_obj['payload']
    for i in payload:
        APPLE_ID = i['apple_id']
        # APP_NAME = i['app_name']
        build_name = i['build_name']
        d.update({build_name: APPLE_ID})
Esempio n. 3
0
def postTestFairyURL(app_name, testfairy_url):
    """
    Post Test Fairy url to Victorious backend

    :param app_name:
        The name of the app to upload the Test Fairy url for.

    :param testfairy_url:
        The Test Fairy url to send to the backend.

    :return:
        0 - For success
        1 - For error
    """

    # Calculate request hash
    uri = '%s/%s' % (_VICTORIOUS_ENDPOINT, app_name)
    url = '%s%s' % (_DEFAULT_HOST, uri)
    date = vams.createDateString()
    req_hash = vams.calcAuthHash(uri, 'POST', date)

    field_name = 'android_testfairy_url'
    if vams._DEFAULT_PLATFORM == vams._PLATFORM_IOS:
        field_name = 'ios_testfairy_url'

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)
    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }
    postData = {
        'build_name': app_name,
        'name': field_name,
        'platform': vams._DEFAULT_PLATFORM,
        'value': testfairy_url
    }
    response = requests.post(url, data=postData, headers=headers)
    json = response.json()
    error_code = json['error']

    if error_code != 0:
        error_message = (
            'Error occurred posting the Test Fairy URL for %s: %s %s' %
            (app_name, error_code, json['message']))
        if _CONSOLE_OUTPUT:
            print error_message
        sys.exit('1|%s' % error_message)

    # Clean-up compiled python files
    cleanUp()

    if _CONSOLE_OUTPUT:
        print 'Test Fairy URL posted successfully for %s!' % app_name
        print ''
Esempio n. 4
0
def retrieveAppDetails(app_name):
    """
    Collects all of the design assets for a given app

    :param app_name:
        The app name of the app whose assets to be downloaded.

    :return:
        0 = Success
        1 = Error
    """

    # Calculate request hash
    uri = '%s/%s' % (_ASSETS_ENDPOINT, app_name)
    url = '%s%s' % (_DEFAULT_HOST, uri)
    date = vams.createDateString()
    req_hash = vams.calcAuthHash(uri, 'GET', date)

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)
    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }
    response = requests.get(url, headers=headers)
    json = response.json()
    error_code = json['error']

    if error_code == 0:
        proccessAppAssets(app_name, json)

    else:
        response_message = (
            'Backend failed retrieving data for %s with error code "%s" and message: "%s"'
            % (app_name, error_code, json['message']))
        if _CONSOLE_OUTPUT:
            print response_message

        cleanUp()

        if vams._DEFAULT_PLATFORM == vams._PLATFORM_IOS:
            shutil.rmtree(_WORKING_DIRECTORY)
            sys.exit('1|%s' % response_message)

        sys.exit(1)
Esempio n. 5
0
def PostToVams(app_name, postData):
    """
    Posts app data to VAMS

    :param app_name:
        Folder name of config data

    :param postData:
        Dictionary of app values to post to VAMS
    """

    print 'Using host: %s' % _DEFAULT_HOST

    app_id = RetrieveAppData(app_name)
    if app_id == 0:
        print 'No app with a build name of \'%s\' was found in VAMS' % app_name
        return 1

    # Add app id to app update object
    postData['app_id'] = app_id

    print 'Posting to VAMS...'

    uri = '%s/%s' % (_VAMS_POST_ENDPOINT, app_name)
    url = '%s%s' % (_DEFAULT_HOST, uri)
    date = vams.createDateString()
    req_hash = vams.calcAuthHash(uri, 'POST', date)

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)
    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }
    response = requests.post(url, data=postData, headers=headers)

    json = response.json()
    error_code = json['error']

    if not error_code == 0:
        print 'An error occurred posting config data to VAMS for %s' % app_name
        print json['message']
    else:
        print 'Config data posted successfully to VAMS for %s' % app_name
Esempio n. 6
0
def fetchAppDetails(server):

    # Calculate request hash
    url = '%s%s' % (_DEFAULT_HOST, app_details_endpoint)

    date = vams.createDateString()

    req_hash = vams.calcAuthHash(app_details_endpoint, 'GET', date)

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)

    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }

    response = requests.get(url, headers=headers)
    print response.text
Esempio n. 7
0
def RetrieveAppData(build_name):
    """
    Retrieve the app details from VAMS

    :param build_name:
        The folder / build_name of the app to retrieve from VAMS

    :return:
        Integer value associated with the app id of the specified app (returns 0 if app is not found)
    """

    # Calculate request hash
    uri = '%s/%s' % (_VAMS_GET_ENDPOINT, build_name)
    url = '%s%s' % (_DEFAULT_HOST, uri)
    date = createDateString()
    req_hash = vams.calcAuthHash(uri, 'GET', date)

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)
    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }
    response = requests.get(url, headers=headers)
    json = response.json()
    error_code = json['error']

    if not error_code == 0:
        print 'An error occurred posting config data for app: %s' % build_name
        print json['message']
        return 0

    payload = json['payload']
    app_id = payload['app_id']

    return app_id
Esempio n. 8
0
def fetchAppList(server):
    """Retrieves the list of ACTIVE (Locked or Unlocked) apps from VAMS.

    Returns:
        List of app info on active apps.
    """

    # Calculate request hash
    url = '%s%s' % (_DEFAULT_HOST, _APPLIST_ENDPOINT)
    date = vams.createDateString()
    req_hash = vams.calcAuthHash(_APPLIST_ENDPOINT, 'GET', date)

    auth_header = 'BASIC %s:%s' % (vams._DEFAULT_VAMS_USERID, req_hash)

    headers = {
        'Authorization': auth_header,
        'User-Agent': vams._DEFAULT_USERAGENT,
        'Date': date
    }
    response = requests.get(url, headers=headers)
    json_obj = response.json()
    error_code = json_obj['error']

    if error_code == 0:
        app_count = 0
        print '\nVAMS Active Apps List'
        print '-----------------------------------------------------------------------------------------------------------------------'
        print 'id   Build Name                              Name                                    Live Version (Google)    Status'
        print '-----------------------------------------------------------------------------------------------------------------------'
        payload = json_obj['payload']
        for app in payload:
            app_id = app['app_id']
            app_state = app['app_state'] if 'app_state' in app else ''
            app_name = app['app_name'] if 'app_name' in app else ''
            build_name = app['build_name'] if 'build_name' in app else ''
            google_play_id = app[
                'google_play_id'] if 'google_play_id' in app else ''

            version = ''
            if google_play_id is not None and google_play_id != '':
                version = retrieveGooglePlayVersion(google_play_id)

            if app_state == vams._STATE_LOCKED:
                state = ccodes.ColorCodes.FAIL + app_state.upper(
                ) + ccodes.ColorCodes.ENDC
            elif app_state == vams._STATE_UNLOCKED:
                state = ccodes.ColorCodes.OKGREEN + app_state.upper(
                ) + ccodes.ColorCodes.ENDC
            else:
                state = ccodes.ColorCodes.OKBLUE + app_state.upper(
                ) + ccodes.ColorCodes.ENDC
            print u' '.join((ccodes.ColorCodes.HEADER + app_id.ljust(5) +
                             ccodes.ColorCodes.ENDC, build_name.ljust(40),
                             app_name.ljust(40), version.ljust(25),
                             state)).encode('utf-8').strip()
            app_count = app_count + 1

        print '-----------------------------------------------------------------------------------------------------------------------'
        print 'Total of %s Apps\nEnvironment: %s\n' % (app_count,
                                                       server.upper())

        return payload

    else:
        print 'No app data found. Uhh... obviously, something went wrong.'
        cleanUp()
        sys.exit(1)