Ejemplo n.º 1
0
Archivo: User.py Proyecto: wwken/kenWeb
def update_fixture_user(user_id, online_status, is_test=True):
    p = {
        'id': user_id,
        'onlineStatus': online_status
    }
    response = request(UPDATE_USER_END_POINT[0], p, is_post=UPDATE_USER_END_POINT[1], is_test=is_test)     # issue http call
    return response
Ejemplo n.º 2
0
def delete_fixture_user_location(id):
    p = {
        'id': id
    }
    response = request(DELETE_USER_LOCATION_END_POINT, p, is_post=True)     # issue http post call
    log.info('delete_fixture_user_location - ' + response)
    return response
Ejemplo n.º 3
0
def update_fixture_user_location(user_id, created_time, ):
    p = {
        'id': user_id,
        'createdTime': created_time
    }
    response = request(UPDATE_USER_LOCATION_END_POINT[0], p, is_post=UPDATE_USER_LOCATION_END_POINT[1])     # issue http post call
    return response
Ejemplo n.º 4
0
def populate_fixture_relation(desc, is_test=True):
    p = {'description': desc}
    response = request(INSERT_RELATION_END_POINT[0],
                       p,
                       is_post=INSERT_RELATION_END_POINT[1],
                       is_test=is_test)  # issue http call
    log.info(response)
Ejemplo n.º 5
0
    def send_sms(self, request):
        logger.info('send sms, request[%s]' % request)
        if request.mobile == '' or request.content == '':
            logger.warning('param error request[%s]' % request)
            return PARAM_ERROR

        param = self.__build_param(request)
        result = http.request(SEND_SMS_URL, param, 'GET', 10)
        if not result:
            return HTTP_REQUEST_ERROR

        logger.debug('result:%s' % result)
        root = None
        sid = request.sid
        errno = 0
        task_id = ''
        valid = 0
        dbstatus = 0
        try:
            root = ET.fromstring(result)
            status = root.find('returnstatus').text
            if status != 'Success':
                msg = root.find('message').text
                logger.warning('send failed, msg[%s]' % msg)
                errno =  SEND_FAILED
            else:
                task_id = root.find('taskID').text
                dbstatus = 1
                valid = 1
        except xml.etree.ElementTree.ParseError:
            logger.warning("invalid result[%s] request[%s]" % (result, request))
            errno = THIRD_SERVER_ERROR
        except Exception, e:
            logger.warning('xml parse exception,ult[%s] request[%s]' % (result, request))
Ejemplo n.º 6
0
def populate_fixture_user_resource(user_id, resource_id, local_path,
                                   file_name):
    p = {
        'id': '' + user_id,
        'resourceId': '' + resource_id,
        'localPath': local_path,
        'fileName': file_name
    }
    response = request(INSERT_END_POINT, p)  # issue http call
    log.info(response)
Ejemplo n.º 7
0
def update_fixture_user_notification(ids_str, is_seen, is_deleted, is_test=True):
    p = {
        'idsStr': ids_str,
        'isSeen': is_seen,
        'isDeleted': is_deleted
    }

    end_point = UPDATE_USER_NOTIFICATION_END_POINT
    response = request(end_point[0], p, is_post=end_point[1], is_test=is_test)     # issue http call
    return response
Ejemplo n.º 8
0
def populate_fixture_user_notification(user_id, issuer_id, notification_id, content, is_test=True):
    p = {
        'id': user_id,
        'issuerId': issuer_id,
        'notificationId': notification_id,
        'content': content
    }

    end_point = INSERT_USER_NOTIFICATION_END_POINT
    response = request(end_point[0], p, is_post=end_point[1], is_test=is_test)     # issue http call
    return response
Ejemplo n.º 9
0
def select_fixture_user_notification(user_id, up_to_how_many_days=None, is_test=True):
    p = {
        'id': user_id
    }

    if not empty(up_to_how_many_days):
        p['upToHowManyDays'] = up_to_how_many_days

    end_point = SELECT_USER_NOTIFICATION_END_POINT
    response = request(end_point[0], p, is_post=end_point[1], is_test=is_test)     # issue http call
    return response
Ejemplo n.º 10
0
def select_fixture_user_location(user_id, relation_id, lnt, lng, radius_in_miles, intention):
    p = {
        'id': user_id,
        'lat': lnt,
        'lng': lng,
        'radiusInMiles': radius_in_miles,
        'intention': intention
    }
    if not empty(relation_id):
        p['relationId'] = relation_id

    response = request(SELECT_USER_LOCATION_END_POINT, p)     # issue http post call
    return response
Ejemplo n.º 11
0
Archivo: User.py Proyecto: wwken/kenWeb
def insert_into_user(facebook_id, google_id, password, email, first_name, last_name, sex, birthday, is_test=True):
    p = {
        'facebookId': facebook_id,
        'googleId': google_id,
        'password': password,
        'email': email,
        'firstName': first_name,
        'lastName': last_name,
        'sex': sex,
        'birthday': birthday
    }

    response = request(INSERT_USER_END_POINT[0], p, is_post=INSERT_USER_END_POINT[1], is_test=is_test)     # issue http call
    return response
Ejemplo n.º 12
0
def populate_fixture_user_location(user_id, lnt, lng, message, user_relation_id=None, timeout=None, radius_in_mile='10'):
    p = {
        'id': user_id,
        'lnt': lnt,
        'lng': lng,
        'message': message
    }

    if not empty(user_relation_id):
        p['userRelationId'] = user_relation_id
    if not empty(timeout):
        p['timeout'] = timeout
    if not empty(radius_in_mile):
        p['radiusInMile'] = radius_in_mile

    response = request(INSERT_USER_LOCATION_END_POINT, p, is_post=True)     # issue http post call
    log.info('populate_fixture_user_location - ' + response)
    return response
Ejemplo n.º 13
0
def populate_fixture_user_relation(user_id,
                                   relation_id,
                                   relation,
                                   description='',
                                   is_update=False,
                                   is_test=True):
    p = {
        'id': user_id,
        'relationId': relation_id,
        'relation': relation,
        'description': description
    }

    end_point = INSERT_USER_RELATION_END_POINT

    if is_update:
        end_point = UPDATE_USER_RELATION_END_POINT

    response = request(end_point[0], p, is_post=end_point[1],
                       is_test=is_test)  # issue http call
    return response
Ejemplo n.º 14
0
def select_fixture_user_resource(user_id, resource_id, http_content_type=None):
    p = {'id': '' + user_id, 'resourceId': '' + resource_id}
    if http_content_type is not None:
        p['httpContentType'] = http_content_type
    response = request(SELECT_USER_RESOURCE_END_POINT, p, is_post=True)
    return response
Ejemplo n.º 15
0
dirpath = env("KENWEB_IMPORT_DIR")
specifiedFile = env("KENWEB_IMPORT_FILE", True)  # optional

onlyfiles = [f for f in listdir(dirpath) if isfile(join(dirpath, f))]

# This is the resourceId in UserResource Table.
# 1 means profile avatar
resource_id = 1

for f in onlyfiles:
    if f.startswith('.'):   # ignore everything start with '.'
        continue

    p = {
        'id': get_file_name_without_extension(f),
        'resourceId': str(resource_id)
    }

    response = request(SELECT_END_POINT, p)     # issue http call

    if empty(response):
        # Insert it to database since it does not exist before
        p['localPath'] = dirpath
        p['fileName'] = f
        response = request(INSERT_END_POINT, p)     # issue http call
        log.info(response)
    else:
        log.info('skipping ' + f)


Ejemplo n.º 16
0
def populate_fixture_notification(desc, template, is_test=True):
    p = {'description': desc, 'template': template}
    request(INSERT_NOTIFICATION_END_POINT[0],
            p,
            is_post=INSERT_NOTIFICATION_END_POINT[1],
            is_test=is_test)  # issue http call