Changeset 16529


Ignore:
Timestamp:
Aug 12, 2016, 9:51:31 AM (3 years ago)
Author:
dferreira
Message:

Changed md5 added to json response

Location:
internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/aptoide_mature_app_detector/explicit_content_detector/API/views.py

    r16527 r16529  
    249249                config = json.load(json_data)
    250250        exp = False
     251        app_md5=0
    251252        try:
    252253                # Fetching the JSON content
     
    277278                                                        else:
    278279                                                                res="no"
    279                                                         return HttpResponse(json.dumps({'app_id': int(app_id), 'status': 'OK','mature_content': res, 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     280                                                        return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id), 'status': 'OK','mature_content': res, 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    280281
    281282                                get_data_async(page, config["directories"]["asynchronous_dir"], cache_reload, "id")
    282                                 return HttpResponse(json.dumps({'app_id': int(app_id), 'status': 'request_submitted','mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     283                                return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id), 'status': 'request_submitted','mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    283284                        exp = get_data_sync(page, int(cache_reload))
    284285
     
    286287                        status = 'Failed'
    287288                        print "App does not exist"
    288                         return HttpResponse(json.dumps({'status': 'Failed', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     289                        return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id),'status': 'Failed', 'mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    289290        except:
    290291                status = 'Failed'
    291292                print "Error during parsing"
    292                 return HttpResponse(json.dumps({'status': 'Failed', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     293                return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id),'status': 'Failed', 'mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    293294
    294295        # If it's explicit content, redirects to true page. Otherwise, redirects to false page.
    295296        if exp:
    296                 return HttpResponse(json.dumps({'app_id': int(app_id), 'status': 'OK','mature_content': 'yes', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    297         return HttpResponse(json.dumps({'app_id': int(app_id), 'status': 'OK','mature_content': 'no', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     297                return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id), 'status': 'OK','mature_content': 'yes', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     298        return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id), 'status': 'OK','mature_content': 'no', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    298299
    299300
     
    343344                                                        else:
    344345                                                                res="no"
    345                                                         return HttpResponse(json.dumps({'app_id': int(app_id), 'status': 'OK','mature_content': res, 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     346                                                        return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id), 'status': 'OK','mature_content': res, 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    346347
    347348                                get_data_async(page, config["directories"]["asynchronous_dir"], cache_reload, "md5")
    348                                 return HttpResponse(json.dumps({'app_id': int(app_id), 'status': 'request_submitted','mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     349                                return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': int(app_id), 'status': 'request_submitted','mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    349350                        exp = get_data_sync(page, int(cache_reload))
    350351
     
    352353                        status = 'Failed'
    353354                        print "App does not exist"
    354                         return HttpResponse(json.dumps({'status': 'Failed', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     355                        return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': app_id,'status': 'Failed', 'mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    355356        except:
    356357                status = 'Failed'
    357358                print "Error during parsing"
    358                 return HttpResponse(json.dumps({'status': 'Failed', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     359                return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': app_id,'status': 'Failed', 'mature_content': '', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    359360
    360361        # If it's explicit content, redirects to true page. Otherwise, redirects to false page.
    361362        if exp:
    362                 return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'yes', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
    363         return HttpResponse(json.dumps({'app_id': app_id, 'status': 'OK','mature_content': 'no', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     363                return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': app_id, 'status': 'OK','mature_content': 'yes', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
     364        return HttpResponse(json.dumps({'app_md5': app_md5,'app_id': app_id, 'status': 'OK','mature_content': 'no', 'time':str(datetime.now()-now)}, sort_keys=True), content_type='application/json')
  • internals/2016/aptoideimagesdetector/trunk/aptoide_mature_app_detector/config.json

    r16528 r16529  
    44                "_Comments":"paths should always be relative to django project (where you run manage.py runserver)",
    55                "_Comments2":"local_or_web_images should be changed to web if you do not have local acess to the images",
    6                 "local_or_web_images":"local",
     6                "local_or_web_images":"web",
    77                "local_image_path_prefix": "imgs",
    88                "ill2vec_ser": "API/Explicit_detector/Illustration2Vector/illustration2vec_master/illust2vec.pickle",
Note: See TracChangeset for help on using the changeset viewer.