コード例 #1
0
ファイル: auth.py プロジェクト: iilab/assembl
 def _do_update_from_json(
         self, json, parse_def, aliases, ctx, permissions,
         user_id, duplicate_error=True):
     # TODO: Verify uniqueness
     json_user_id = json.get('user', None)
     if json_user_id is None:
         json_user_id = user_id
     else:
         json_user_id = User.get_database_id(json_user_id)
         # Do not allow changing user
         if self.user_id is not None and json_user_id != self.user_id:
             raise HTTPBadRequest()
     self.user_id = json_user_id
     role_name = json.get("role", None)
     if not (role_name or self.role_id):
         role_name = R_PARTICIPANT
     if role_name:
         role = self.db.query(Role).filter_by(name=role_name).first()
         if not role:
             raise HTTPBadRequest("Invalid role name:"+role_name)
         self.role = role
     json_discussion_id = json.get('discussion', None)
     if json_discussion_id:
         from .discussion import Discussion
         json_discussion_id = Discussion.get_database_id(json_discussion_id)
         # Do not allow change of discussion
         if self.discussion_id is not None \
                 and json_discussion_id != self.discussion_id:
             raise HTTPBadRequest()
         self.discussion_id = json_discussion_id
     else:
         if not self.discussion_id:
             raise HTTPBadRequest()
     return self
コード例 #2
0
    def dump_data(self, json):
        self._count = json.get("count")
        self._hex_count = json.get("hexcodecount")
        self._name = json.get("name")

        self.set_count(self._count)
        self.set_hex_count(self._hex_count)
        self.set_name(self._name)
コード例 #3
0
	def dump_data(self,json):
		self._count = json.get("count")
		self._hex_count = json.get("hexcodecount")
		self._name = json.get("name")

		self.set_count(self._count)
		self.set_hex_count(self._hex_count)
		self.set_name(self._name)
コード例 #4
0
ファイル: __init__.py プロジェクト: c0ns0le/Pythonista
 def _set_artist(self, json):
     if json.get('artistId'):
         id = json['artistId']
         self.artist = Artist(id)
         self.artist._set(json)
     elif json.get('artistName'):
         self.artist = json['artistName']
     else:
         self.artist = None
コード例 #5
0
    def dump_data(self, json):
        self._block = json.get("block")
        self._size = json.get("size")
        self._mean = json.get("mean")
        self._offset = json.get("offset")

        self.set_block(self._block)
        self.set_size(self._size)
        self.set_mean(self._mean)
        self.set_offset(self._offset)
コード例 #6
0
ファイル: malobjclass.py プロジェクト: cvandeplas/pdfxray
	def shallow_diver(self,json,shell):
		for key, value in json.iteritems():
			if shell == key:
				data = json.get(shell)
				break
			else:
				if shell in value:
					data = json.get(key)
					data = self.shallow_diver(data,shell)
		return data
コード例 #7
0
	def dump_data(self,json):
		self._block = json.get("block")
		self._size = json.get("size")
		self._mean = json.get("mean")
		self._offset = json.get("offset")

		self.set_block(self._block)
		self.set_size(self._size)
		self.set_mean(self._mean)
		self.set_offset(self._offset)
コード例 #8
0
def post_event_participant(event_id):
    participant = None
    create = False
    try:
        json = request.get_json()

        if json.get('id', None) != None:
            participant = Participant.query.filter(Participant.id == json['id']).first()

        if participant == None:
            participant = Participant()
            create = True

        participant.first_name = json['first_name']
        participant.last_name = json['last_name']
        participant.email = json.get('email', None)
        participant.phone = json.get('phone', None)
        participant.age = json.get('age', None)
        participant.den = json.get('den', None)
        participant.participant_type = json['participant_type']
        participant.allergies = json['allergies']
        participant.dietary_restrictions = json['dietary_restrictions']
        participant.event_id = json['event_id']
        participant.registration_id = json['registration_id']
        
        if create:
            db.session.add(participant)
        
        db.session.commit()

    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        f = io.StringIO()
        traceback.print_tb(exc_traceback, file=f)
        msg = None
        if exc_value is None:
            msg = "Unexpected error: {err}\nTraceback: {tb}".format(err=exc_type,tb=f.getvalue()), 500
        else:
            msg = "Unexpected error: {err}\nMessage: {msg}\nTraceback: {tb}".format(err=exc_type,msg=exc_value,tb=f.getvalue())
        app.logger.error(msg)
        return  msg, 500

    return jsonify(
            id=participant.id,
            first_name=participant.first_name, 
            last_name=participant.last_name, 
            email=participant.email, 
            phone=participant.phone, 
            age=participant.age, 
            den=participant.den, 
            participant_type=participant.participant_type,
            allergies=participant.allergies,
            dietary_restrictions=participant.dietary_restrictions,
            event_id=participant.event_id,
            registration_id=participant.registration_id), 201
コード例 #9
0
    def shallow_diver(self, json, shell):
        for key, value in json.iteritems():
            if shell == key:
                data = json.get(shell)
                break
            else:
                if shell in value:
                    data = json.get(key)
                    data = self.shallow_diver(data, shell)

        return data
コード例 #10
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
    def _set(self, json):
        super(Album, self)._set(json)
        # Collection information
        self.name = json['collectionName']
        self.url = json.get('collectionViewUrl', None)
        self.amg_id = json.get('amgAlbumId', None)

        self.price = round(json.get('collectionPrice', 0) or 0, 4)
        self.price_currency = json['currency']
        self.track_count = json['trackCount']
        self.copyright = json.get('copyright', None)

        self._set_artist(json)
コード例 #11
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
    def _set(self, json):
        super(Album, self)._set(json)
        # Collection information
        self.name = json['collectionName']
        self.url = json.get('collectionViewUrl', None)
        self.amg_id = json.get('amgAlbumId', None)

        self.price = round(json.get('collectionPrice', 0) or 0, 4)
        self.price_currency = json['currency']
        self.track_count = json['trackCount']
        self.copyright = json.get('copyright', None)

        self._set_artist(json)
コード例 #12
0
ファイル: controllers.py プロジェクト: yuancloud/yuancloud
 def weixin_validate_data(self, postdata):
     cr, uid, context = request.cr, request.uid, request.context
     json = {}
     for el in etree.fromstring(postdata):
         json[el.tag] = el.text
     try:
         appid = json['appid']
         _KEY = request.env['payment.acquirer'].search([
             ('weixin_officialaccount.wx_appid', '=', appid)
         ])[0].weixin_officialaccount.wx_mch_secret
         print _KEY
     except:
         _KEY = "1qaz2wsx3edc4rfv5tgb6yhn7ujm8ik9"
     txs = request.env['payment.transaction'].search([
         ('reference', '=', json['out_trade_no'])
     ])
     if not txs and len(txs) > 1 and txs[0].state == 'done':
         return 'success'
     _, prestr = util.params_filter(json)
     mysign = util.build_mysign(prestr, _KEY, 'MD5')
     if mysign != json.get('sign'):
         _logger.info("签名错误")
         return 'false'
     _logger.info('weixin: validated data')
     return request.registry['payment.transaction'].form_feedback(
         cr, SUPERUSER_ID, json, 'weixin', context=context)
コード例 #13
0
ファイル: __init__.py プロジェクト: paul-obrien/python-itunes
    def _set(self, json):
        super(Track, self)._set(json)
        # Track information
        self.name = json['trackName']
        self.url = json.get('trackViewUrl', None)
        self.preview_url = json.get('previewUrl', None)
        self.price = None
        if json.has_key('trackPrice') and json['trackPrice'] is not None:
            self.price = round(json['trackPrice'], 4)
        self.number = json.get('trackNumber', None)
        self.duration = None
        if json.has_key('trackTimeMillis') and json['trackTimeMillis'] is not None:
            self.duration = round(json.get('trackTimeMillis', 0.0)/1000.0, 2)

        self._set_artist(json)
        self._set_album(json)
コード例 #14
0
ファイル: collector.py プロジェクト: superxiaoqiang/bitcoin
def get_orders2(url):
    params = get_query_parameters(url)
    json = get_json(url, params)
    # print json
    data = json.get("return")
    if url.find("mtgox") != -1:
        bids = []
        bidsJson = data.get("bids")
        for bid in bidsJson:
            b = []
            b.append(bid.get("price"))
            b.append(bid.get("amount"))
            bids.append(b)

        asks = []
        asksJson = data.get("asks")
        for ask in asksJson:
            b = []
            b.append(ask.get("price"))
            b.append(ask.get("amount"))
            asks.append(b)

        return bids, asks
    else:
        orders = data.get("bids"), data.get("asks")
        # print orders
        return orders
コード例 #15
0
ファイル: collector.py プロジェクト: superxiaoqiang/bitcoin
def get_orders(url, params):
    json = get_json(url, params)
    # print json
    data = json.get("return")
    orders = data.get("bids"), data.get("asks")
    # print orders
    return orders
コード例 #16
0
def get_orders(url,params):
    json = get_json(url,params)
    #print json
    data = json.get('return')
    orders = data.get('bids'),data.get('asks')
    #print orders
    return orders
コード例 #17
0
def get_orders2(url):
    params = get_query_parameters(url)
    json = get_json(url,params)
    #print json
    data = json.get('return')
    if (url.find('mtgox') != -1):
        bids = []
        bidsJson = data.get('bids')
        for bid in bidsJson:
            b = []
            b.append(bid.get('price'))
            b.append(bid.get('amount'))
            bids.append(b)
            
        asks = []
        asksJson = data.get('asks')
        for ask in asksJson:
            b = []
            b.append(ask.get('price'))
            b.append(ask.get('amount'))
            asks.append(b)
            
        return bids,asks
    else:
        orders = data.get('bids'),data.get('asks')
        #print orders
        return orders
コード例 #18
0
 def extract(self):
     global api
     
     start_time = current_time()
     api=api.replace("eventStartFrom=YYYY-MM-DDTHH:MM:SS","eventStartFrom="+str(arrow.utcnow().replace(hours=-hours_back))[0:19])
     api=api.replace("eventStartTo=YYYY-MM-DDTHH:MM:SS", "eventStartTo="+str(arrow.utcnow().replace(hours=+hours_forward))[0:19])
     response = requests.get(api)
     json = response.json()
     print("time to get: " + str(current_time()-start_time))
     
     games = json.get(ROOT)        
     for game in games:
         id = game.get(ID) 
         time = format_time(BETSSON,game.get(TIME).replace("T"," ").replace("Z",""))
         region = game.get(REGION)
         league = game.get(LEAGUE)
         home = game.get(TEAMS)[HOME].get(TEAM)
         away = game.get(TEAMS)[AWAY].get(TEAM)
         print(home + " " + away)
         bets = game.get(BET_TYPES)[MATCH_WINNER].get(MATCH_WINNER_BETS)
         home_bet = bets[HOME_BET].get(BET)
         draw_bet = bets[DRAW_BET].get(BET)
         away_bet = bets[AWAY_BET].get(BET) 
         
         match_id_query = process_query(home,away)            
         match_id = get_match_id(driver,match_id_query,time,None).decode('utf-8')
         #print(match_id)
         print(str(id) + " " + time + " " + league + " " + home + " " + away + " " + str(home_bet) + " " + str(draw_bet) + " " + str(away_bet) + " " + match_id)       
コード例 #19
0
    def _do_create_from_json(cls,
                             json,
                             parse_def,
                             context,
                             duplicate_handling=None,
                             object_importer=None):
        # Special case for JSON-LD
        added = False
        ls = cls()

        def guess_lang(value):
            from .discussion import Discussion
            discussion = context.get_instance_of_class(Discussion)
            if discussion:
                tr_service = discussion.translation_service()
                lang, _ = tr_service.identify(value)
            return LocaleLabel.UNDEFINED

        if isinstance(json, list):
            for entry_record in json:
                value = entry_record['@value']
                if value:
                    added = True
                    lang = entry_record.get('@language',
                                            None) or guess_lang(value)
                    ls.add_value(value, lang)
        elif isinstance(json, dict):
            if '@id' in json or '@type' in json:
                return super(LangString,
                             cls)._do_create_from_json(json, parse_def,
                                                       context,
                                                       duplicate_handling,
                                                       object_importer)
            elif '@value' in json:
                value = json['@value']
                if value:
                    added = True
                    lang = json.get('@language', None) or guess_lang(value)
                    ls.add_value(value, lang)
            else:
                for lang, value in json.items():
                    if value:
                        added = True
                        ls.add_value(value, lang)
        elif isinstance(json, string_types):
            if json:
                added = True
                lang = guess_lang(json)
                ls.add_value(json, lang)
        else:
            raise ValueError("Not a valid langstring: " + json)
        i_context = ls.get_instance_context(context)
        if added:
            cls.default_db.add(ls)
        else:
            i_context._instance = None
        return i_context
コード例 #20
0
 def class_from_data(self, json):
     typename = json.get('@type')
     # Look for aliased classes.
     # Maybe look in the context instead?
     typename = self.equivalents.get(typename, typename)
     if typename:
         cls = get_named_class(typename)
         # TODO: Adjust for subclasses according to json record
         # cls = cls.get_jsonld_subclass(json)
         return cls
コード例 #21
0
ファイル: main.py プロジェクト: zlcoming/payment
    def weixin_validate_data(self, xml):
        json = {}
        for el in etree.fromstring(xml):
            json[el.tag] = el.text

        acquirer = request.env['payment.acquirer'].search(
            [('weixin_appid', '=', json.get('appid'))], limit=1)

        _KEY = acquirer.weixin_key
        _logger.info('weixin key: %s' % _KEY)
        if not _KEY:
            return False

        _, prestr = util.params_filter(json)
        mysign = util.build_mysign(prestr, _KEY, 'MD5')
        if mysign != json.get('sign'):
            return False

        _logger.info('weixin: data validated!')
        return True
コード例 #22
0
 def _set(self, json):
     super(Track, self)._set(json)
     # Track information
     self.name = json['trackName']
     self.url = json.get('trackViewUrl', None)
     self.preview_url = json.get('previewUrl', None)
     self.price = None
     if json.has_key('trackPrice') and json['trackPrice'] is not None:
         self.price = round(json['trackPrice'], 4)
     self.number = json.get('trackNumber', None)
     self.duration = None
     if json.has_key('trackTimeMillis') and json['trackTimeMillis'] is not None:
         self.duration = round(json.get('trackTimeMillis', 0.0)/1000.0, 2)
     try:
         self._set_artist(json)
     except KeyError:
         self.artist = None
     try:
         self._set_album(json)
     except KeyError:
         self.album = None
コード例 #23
0
ファイル: main.py プロジェクト: jeffery9/payment
    def weixin_validate_data(self, xml):
        json = {}
        for el in etree.fromstring(xml):
            json[el.tag] = el.text

        acquirer = request.env['payment.acquirer'].search(
            [('weixin_appid', '=', json.get('appid'))], limit=1
        )

        _KEY = acquirer.weixin_key
        _logger.info('weixin key: %s' % _KEY)
        if not _KEY:
            return False

        _, prestr = util.params_filter(json)
        mysign = util.build_mysign(prestr, _KEY, 'MD5')
        if mysign != json.get('sign'):
            return False

        _logger.info('weixin: data validated!')
        return True
コード例 #24
0
ファイル: __init__.py プロジェクト: Smenus/python-itunes
 def _set(self, json):
     super(Track, self)._set(json)
     # Track information
     self.name = json['trackName']
     self.url = json.get('trackViewUrl', None)
     self.preview_url = json.get('previewUrl', None)
     self.price = None
     if 'trackPrice' in json and json['trackPrice'] is not None:
         self.price = round(json['trackPrice'], 4)
     self.number = json.get('trackNumber', None)
     self.duration = None
     if 'trackTimeMillis' in json and json['trackTimeMillis'] is not None:
         self.duration = round(json.get('trackTimeMillis', 0.0)/1000.0, 2)
     try:
         self._set_artist(json)
     except KeyError:
         self.artist = None
     try:
         self._set_album(json)
     except KeyError:
         self.album = None
コード例 #25
0
 def _do_update_from_json(self,
                          json,
                          parse_def,
                          context,
                          duplicate_handling=None,
                          object_importer=None):
     # Special case for JSON-LD
     if isinstance(json, list):
         for entry_record in json:
             lang = entry_record.get('@language', LocaleLabel.UNDEFINED)
             value = entry_record['@value']
             entry = self.entries_as_dict.get(lang, None)
             if entry:
                 entry.set_value(value)
             elif value:
                 self.add_value(value, lang)
     elif isinstance(json, dict):
         if '@id' in json or '@type' in json:
             return super(LangString, self)._do_update_from_json(
                 json, parse_def, context, duplicate_handling,
                 object_importer)
         elif '@value' in json:
             value = json['@value']
             if value:
                 lang = json.get('@language', LocaleLabel.UNDEFINED)
                 entry = self.entries_as_dict.get(lang, None)
                 if entry:
                     entry.set_value(value)
                 elif value:
                     self.add_value(value, lang)
         else:
             for lang, value in json.items():
                 entry = self.entries_as_dict.get(lang, None)
                 if entry:
                     entry.set_value(value)
                 elif value:
                     self.add_value(value, lang)
     elif isinstance(json, string_types):
         from .discussion import Discussion
         lang = LocaleLabel.UNDEFINED
         discussion = context.get_instance_of_class(Discussion)
         if discussion:
             tr_service = discussion.translation_service()
             lang, _ = tr_service.identify(json)
         entry = self.entries_as_dict.get(lang, None)
         if entry:
             entry.set_value(json)
         elif json:
             self.add_value(json, lang)
     else:
         raise ValueError("Not a valid langstring: " + json)
     return self
コード例 #26
0
    def weixin_validate_data(self, **post):
        cr, uid, context = request.cr, request.uid, request.context
        json = {}
        for el in etree.fromstring(post):
            json[el.tag] = el.text

        _KEY = request.registry['payment.acquirer']._get_weixin_key()
        _, prestr = util.params_filter(json)
        mysign = util.build_mysign(prestr, _KEY, 'MD5')
        if mysign != json.get('sign'):
            return 'false'

        _logger.info('weixin: validated data')
        return request.registry['payment.transaction'].form_feedback(cr, SUPERUSER_ID, json, 'weixin',
                                                                     context=context)
コード例 #27
0
ファイル: malobjclass.py プロジェクト: 7h3rAm/malpdfobj
	def dump_data(self,json):
		self._decoded = json.get("decoded")
		self._encoded = json.get("encoded")
		self._hex = json.get("hex")
		self._id = json.get("id")
		self._length = json.get("length")
		self._hash = json.get("md5")
		self._suspicious = json.get("suspicious")
		self._version = json.get("version")

		self.set_decoded(self._decoded)
		self.set_encoded(self._encoded)
		self.set_hex(self._hex)
		self.set_id(self._id)
		self.set_length(self._length)
		self.set_hash(self._hash)
		self.set_suspicious(self._suspicious)
		self.set_version(self._version)
コード例 #28
0
    def dump_data(self, json):
        self._decoded = json.get("decoded")
        self._encoded = json.get("encoded")
        self._hex = json.get("hex")
        self._id = json.get("id")
        self._length = json.get("length")
        self._hash = json.get("md5")
        self._suspicious = json.get("suspicious")
        self._version = json.get("version")

        self.set_decoded(self._decoded)
        self.set_encoded(self._encoded)
        self.set_hex(self._hex)
        self.set_id(self._id)
        self.set_length(self._length)
        self.set_hash(self._hash)
        self.set_suspicious(self._suspicious)
        self.set_version(self._version)
コード例 #29
0
ファイル: jsonld_reader.py プロジェクト: rmoorman/assembl
    def read(self, jsonld, discussion, admin_user_id, base=None):
        if isinstance(jsonld, (str, unicode)):
            jsonld = json.loads(jsonld)
        c = jsonld['@context']
        # Avoid loading the main context.
        if c == context_url:
            c = local_context_loc
        elif context_url in c:
            c.remove(context_url)
            c.append(local_context_loc)
        c = Context(c, base=base)
        by_id = dict()
        site_iri = None

        def find_objects(j):
            if isinstance(jsonld, (str, unicode)):
                return
            if isinstance(j, list):
                for x in j:
                    find_objects(x)
            if isinstance(j, dict):
                jid = j.get('@id', None)
                if jid:
                    by_id[jid] = j
                for x in j.values():
                    find_objects(x)
        find_objects(jsonld)
        for json in by_id.itervalues():
            if json.get('@type', None) == 'Site':
                site_iri = json['@id']
                break
        site_iri = site_iri or base
        assert site_iri is not None
        handler = ImportRecordHandler(discussion, site_iri)
        for json in by_id.itervalues():
            cls = self.class_from_type(json['@type'])
            if not cls:
                print "missing cls for :", json['@type']
                continue
            if cls:
                cls = get_named_class(cls)
            cls.create_from_json(
                json, admin_user_id, aliases=handler,
                parse_def_name='readcif.json', jsonld=by_id)
コード例 #30
0
ファイル: widgets.py プロジェクト: hypnotics/assembl
 def update_from_json(self, json, user_id=Everyone, ctx=None):
     from ..auth.util import user_has_permission
     if user_has_permission(self.discussion_id, user_id, P_ADMIN_DISC):
         new_type = json.get('@type', self.type)
         if self.type != new_type:
             polymap = inspect(self.__class__).polymorphic_identity
             if new_type not in polymap:
                 return None
             new_type = polymap[new_type].class_
             new_instance = self.change_class(new_type)
             return new_instance.update_from_json(json, user_id, ctx)
         if 'settings' in json:
             self.settings_json = json['settings']
         if 'discussion' in json:
             self.discussion = Discussion.get_instance(json['discussion'])
     if 'state' in json:
         self.state_json = json['state']
     if user_id and user_id != Everyone and 'user_state' in json:
         self.set_user_state(json['user_state'], user_id)
     return self
コード例 #31
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_num_ratings(self, json, only_current_version=False):
     if only_current_version:
         self.num_ratings = json.get('userRatingCountForCurrentVersion',
                                     None)
     else:
         self.num_ratings = json.get('userRatingCount', None)
コード例 #32
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_languages(self, json):
     self.languages = json.get('languageCodesISO2A', None)
コード例 #33
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_avg_rating(self, json, only_current_version=False):
     if only_current_version:
         self.avg_rating = json.get('averageUserRatingForCurrentVersion', None)
     else:
         self.avg_rating = json.get('averageUserRating', None)
コード例 #34
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_artist(self, json):
     self.artist = None
     if json.get('artistId'):
         id = json['artistId']
         self.artist = Artist(id)
         self.artist._set(json)
コード例 #35
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set(self, json):
     super(Artist, self)._set(json)
     self.name = json['artistName']
     self.amg_id = json.get('amgArtistId', None)
     self.url = json.get('artistViewUrl', json.get('artistLinkUrl', None))
コード例 #36
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_genre(self, json):
     self.genre = json.get('primaryGenreName', None)
コード例 #37
0
 def add_related(self, json):
     related = json.get("related")
     objects = related.get("objects")
     for related in objects:
         irobj = rObj(related)
         self._robjs.append(irobj)
コード例 #38
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_price(self, json):
     self.price = json.get('price', None)
コード例 #39
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_description(self, json):
     self.description = json.get('description', None)
コード例 #40
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_screenshots(self, json):
     self.screenshots = json.get('screenshotUrls', None)
コード例 #41
0
	def dump_data(self,json):
		self._obj_hash = json.get("sobj_hash")	
		self._obj_id = json.get("sobj_id")
		self._match = json.get("matches")
		self.process_matches(self._match)
		self.set_matches(self._matches)
コード例 #42
0
    def dump_data(self, json):
        self._contains_js = json.get("contains_js")
        self._errors = json.get("errors")
        try:
            self._contains_flash = json.get("contains_flash")
        except:
            fail = None
        self._stream = json.get("stream")
        if len(self._stream) > 0:
            self._stream_decoded_hash = self._stream.get("decoded_hash")
            self._stream_decoded_hex = self._stream.get("decoded_hex")
            self._stream_decoded_stream = self._stream.get("decoded_stream")
            self._stream_decoded_errors = self._stream.get("decoded_errors")
            self._stream_encoded_hash = self._stream.get("encoded_hash")
            self._stream_encoded_hex = self._stream.get("encoded_hex")
            self._stream_encoded_stream = self._stream.get("encoded_stream")
            self._stream_filter = self._stream.get("filter")
            self._stream_js_code = self._stream.get("js_code")
            self._stream_size = self._stream.get("size")
            self._stream_entropy = self._stream.get("entropy")
            self._stream_flags = self._stream.get("flags")
        self._raw_hash = json.get("raw_hash")
        self._vulns = json.get("vulns")
        self._encrypted = json.get("encrypted")
        self._suspicious_actions = json.get("suspicious_actions")
        self._suspicious_elements = json.get("suspicious_elements")
        self._suspicious_events = json.get("suspicious_events")
        self._raw = json.get("raw")
        self._references = json.get("references")
        self._offset = json.get("offset")
        self._id = json.get("id")
        self._size = json.get("size")

        self.process_entropy(self._stream_entropy)
        self.process_flags(self._stream_flags)
        self.generate_derived_string()
コード例 #43
0
	def dump_data(self,json):
		self._parent_file_hash = json.get("parent_file_hash")
		self._obj_hash = json.get("mobj_hash")	
		self._obj_id = json.get("mobj_id")
コード例 #44
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_price(self, json):
     self.price = json.get('price', None)
コード例 #45
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_country(self, json):
     self.country_store = json.get('country', None)
コード例 #46
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_screenshots(self, json):
     self.screenshots = json.get('screenshotUrls', None)
コード例 #47
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_avg_rating(self, json, only_current_version=False):
     if only_current_version:
         self.avg_rating = json.get('averageUserRatingForCurrentVersion',
                                    None)
     else:
         self.avg_rating = json.get('averageUserRating', None)
コード例 #48
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_seller_url(self, json):
     self.seller_url = json.get('sellerUrl', None)
コード例 #49
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_version(self, json):
     self.version = json.get('version', None)
コード例 #50
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_genres(self, json):
     self.genres = json.get('genres', None)
コード例 #51
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_description(self, json):
     self.description = json.get('description', None)
コード例 #52
0
 def dump_data(self, json):
     self._obj_hash = json.get("sobj_hash")
     self._obj_id = json.get("sobj_id")
     self._match = json.get("matches")
     self.process_matches(self._match)
     self.set_matches(self._matches)
コード例 #53
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_genres(self, json):
     self.genres = json.get('genres', None)
コード例 #54
0
 def dump_data(self, json):
     self._parent_file_hash = json.get("parent_file_hash")
     self._obj_hash = json.get("mobj_hash")
     self._obj_id = json.get("mobj_id")
コード例 #55
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_languages(self, json):
     self.languages = json.get('languageCodesISO2A', None)
コード例 #56
0
ファイル: __init__.py プロジェクト: rsumner33/python-itunes-2
 def _set_seller_url(self, json):
     self.seller_url = json.get('sellerUrl', None)
コード例 #57
0
ファイル: __init__.py プロジェクト: flyhawk007/python-itunes
 def _set_num_ratings(self, json, only_current_version=False):
     if only_current_version:
         self.num_ratings = json.get('userRatingCountForCurrentVersion', None)
     else:
         self.num_ratings = json.get('userRatingCount', None)
コード例 #58
0
def handle_event_registration_completion(event_id, registration_id):
    try:
        registration = Registration.query.filter(and_(Registration.id == registration_id, Registration.event_id == event_id)).first()

        if registration.completed:
            return '', 200

        total = Decimal(value='0.00')
        json = request.get_json()
        payment_type = json['payment_type']
        test = json.get('test', False)
        settings = Settings.query.get(1)
        event = Event.query.filter(Event.id == event_id).first()
        prices = EventPrice.query.filter(EventPrice.event_id == event_id).all()
        participants = Participant.query.filter(Participant.registration_id == registration_id).all()

        d = {}

        order_items = []

        for participant in participants:
            l = d.get(participant.participant_type, [])
            l.append(participant)
            d[participant.participant_type] = l

        for key in d:
            l = d.get(key)
            price = None
            for event_price in prices:
                if event_price.participant_type == l[0].participant_type:
                    price = event_price
                    break
            item = OrderItem()
            
            if payment_type == 'PayPal':
                item.amount = (price.price * len(l)) / (Decimal(value='1.00') - settings.paypal_rate)
            else:
                item.amount = price.price * len(l)
            item.quantity = 1
            item.name = "{participant_type} {event_name} registration".format(participant_type=l[0].participant_type, event_name=event.name)
            item.event_id = event_id
            item.registration_id = registration_id
            db.session.add(item)
            order_items.append(item)

            total = total + item.amount

        if payment_type == 'PayPal':
            item.amount = settings.paypal_surcharge
            item.quantity = 1
            item.name = 'PayPal processing fee'
            item.event_id = event_id
            item.registration_id = registration_id
            db.session.add(item)
            order_items.append(item)

            total = total + item.amount

        registration.completed = True

        db.session.commit()

        send_participant_emails(settings, event_id, registration_id, order_items, total, test=test)
    except:
        exc_type, exc_value, exc_traceback = sys.exc_info()
        f = io.StringIO()
        traceback.print_tb(exc_traceback, file=f)
        msg = None
        if exc_value is None:
            msg = "Unexpected error: {err}\nTraceback: {tb}".format(err=exc_type,tb=f.getvalue())
        else:
            msg = "Unexpected error: {err}\nMessage: {msg}\nTraceback: {tb}".format(err=exc_type,msg=exc_value,tb=f.getvalue())
        app.logger.error(msg)
        return  msg, 500
    return '', 202