How to use encode_id method in devtools-proxy

Best Python code snippet using devtools-proxy_python

test_latest_transaction_explorer_values.py

Source:test_latest_transaction_explorer_values.py Github

copy

Full Screen

...16 'transactions_explorer_example_data.json'), 'r') as f:17 data = json.loads(f.read())18data_to_post = [19 {20 "_id": encode_id('quart', 'digital_cost_per_transaction'),21 "_timestamp": "2014-12-12T00:00:00+00:00",22 "digital_cost_per_transaction": None,23 "end_at": "2013-01-01T00:00:00+00:00",24 "period": "year",25 "service_id": "service-with-quarterly-not-latest",26 "dashboard_slug": "quart",27 "type": "quarterly"28 },29 {30 '_timestamp': u'2014-12-12T00:00:00+00:00',31 "_id": encode_id('quart', 'digital_takeup'),32 'period': u'year',33 'end_at': u'2013-01-01T00:00:00+00:00',34 'dashboard_slug': 'quart',35 'service_id': u'service-with-quarterly-not-latest',36 'digital_takeup': None,37 "type": "quarterly"38 },39 {40 "_id": encode_id('quarterly-nonsense', 'digital_cost_per_transaction'),41 "_timestamp": "2014-12-12T00:00:00+00:00",42 "digital_cost_per_transaction": 2.36,43 "end_at": "2013-01-01T00:00:00+00:00",44 "period": "year",45 "service_id": "service-with-quarterly-data",46 "dashboard_slug": "quarterly-nonsense",47 "type": "quarterly"48 },49 {50 '_timestamp': u'2014-12-12T00:00:00+00:00',51 "_id": encode_id('quarterly-nonsense', 'digital_takeup'),52 'period': u'year',53 'end_at': u'2013-01-01T00:00:00+00:00',54 'dashboard_slug': 'quarterly-nonsense',55 'service_id': u'service-with-quarterly-data',56 'digital_takeup': None,57 'type': u'quarterly'58 },59 {60 "_id": encode_id(61 'quarterly-nonsense2',62 'digital_cost_per_transaction'),63 "_timestamp": "2014-12-12T00:00:00+00:00",64 "digital_cost_per_transaction": 2.36,65 "end_at": "2013-01-01T00:00:00+00:00",66 "period": "year",67 "service_id": "service-with-quarterly-data",68 "dashboard_slug": "quarterly-nonsense2",69 "type": "quarterly"70 },71 {72 '_timestamp': u'2014-12-12T00:00:00+00:00',73 "_id": encode_id('quarterly-nonsense2', 'digital_takeup'),74 'period': u'year',75 'end_at': u'2013-01-01T00:00:00+00:00',76 'dashboard_slug': 'quarterly-nonsense2',77 'service_id': u'service-with-quarterly-data',78 'digital_takeup': None,79 'type': u'quarterly'80 },81 {82 "_id": encode_id('sorn', 'cost_per_transaction'),83 "_timestamp": "2013-04-01T00:00:00+00:00",84 "cost_per_transaction": None,85 "end_at": "2012-04-01T00:00:00+00:00",86 "period": "year",87 "service_id": "sorn-innit",88 "dashboard_slug": "sorn",89 "type": "seasonally-adjusted"90 },91 {92 "_id": encode_id('sorn', 'digital_cost_per_transaction'),93 "_timestamp": "2013-04-01T00:00:00+00:00",94 "digital_cost_per_transaction": None,95 "end_at": "2012-04-01T00:00:00+00:00",96 "period": "year",97 "service_id": "sorn-innit",98 "dashboard_slug": "sorn",99 "type": "seasonally-adjusted"100 },101 {102 # It looks like this id generation is correct.103 # The latest data point transform takes the data_type104 # as the second argument. In the case of digital_takeup105 # the data_type is digital_takeup.106 "_id": encode_id('sorn', 'digital_takeup'),107 "_timestamp": "2013-04-01T00:00:00+00:00",108 "digital_takeup": None,109 "end_at": "2012-04-01T00:00:00+00:00",110 "period": "year",111 "service_id": "sorn-innit",112 "dashboard_slug": "sorn",113 "type": "seasonally-adjusted"114 },115 {116 "_id": encode_id('sorn', 'number_of_digital_transactions'),117 "_timestamp": "2013-04-01T00:00:00+00:00",118 "end_at": "2012-04-01T00:00:00+00:00",119 "number_of_digital_transactions": None,120 "period": "year",121 "service_id": "sorn-innit",122 "dashboard_slug": "sorn",123 "type": "seasonally-adjusted"124 },125 {126 "_id": encode_id('sorn', 'total_cost'),127 "_timestamp": "2013-04-01T00:00:00+00:00",128 "end_at": "2012-04-01T00:00:00+00:00",129 "period": "year",130 "service_id": "sorn-innit",131 "dashboard_slug": "sorn",132 "total_cost": None,133 "type": "seasonally-adjusted"134 },135 {136 '_timestamp': u'2013-04-01T00:00:00+00:00',137 'period': u'year',138 'end_at': u'2012-04-01T00:00:00+00:00',139 'number_of_transactions': None,140 'dashboard_slug': 'sorn',141 'service_id': u'sorn-innit',142 "_id": encode_id('sorn', 'number_of_transactions'),143 'type': u'seasonally-adjusted'144 },145 {146 "_id": encode_id('bis-returns', 'cost_per_transaction'),147 "_timestamp": "2013-04-01T00:00:00+00:00",148 "cost_per_transaction": 5.2,149 "end_at": "2012-04-01T00:00:00+00:00",150 "period": "year",151 "service_id": "bis-annual-returns",152 "dashboard_slug": "bis-returns",153 "type": "seasonally-adjusted"154 },155 {156 "_id": encode_id('bis-returns', 'digital_cost_per_transaction'),157 "_timestamp": "2013-04-01T00:00:00+00:00",158 "digital_cost_per_transaction": 2.52,159 "end_at": "2012-04-01T00:00:00+00:00",160 "period": "year",161 "service_id": "bis-annual-returns",162 "dashboard_slug": "bis-returns",163 "type": "seasonally-adjusted"164 },165 {166 "_id": encode_id('bis-returns', 'digital_takeup'),167 "_timestamp": "2013-04-01T00:00:00+00:00",168 "digital_takeup": 0.965537995968002,169 "end_at": "2012-04-01T00:00:00+00:00",170 "period": "year",171 "service_id": "bis-annual-returns",172 "dashboard_slug": "bis-returns",173 "type": "seasonally-adjusted"174 },175 {176 "_id": encode_id('bis-returns', 'number_of_transactions'),177 "_timestamp": "2013-04-01T00:00:00+00:00",178 "end_at": "2012-04-01T00:00:00+00:00",179 "number_of_transactions": 2262898,180 "period": "year",181 "service_id": "bis-annual-returns",182 "dashboard_slug": "bis-returns",183 "type": "seasonally-adjusted"184 },185 {186 "_id": encode_id('bis-returns', 'total_cost'),187 "_timestamp": "2013-04-01T00:00:00+00:00",188 "end_at": "2012-04-01T00:00:00+00:00",189 "period": "year",190 "service_id": "bis-annual-returns",191 "dashboard_slug": "bis-returns",192 "total_cost": 11767069.6,193 "type": "seasonally-adjusted"194 },195 {196 'number_of_digital_transactions': None,197 '_timestamp': u'2013-04-01T00:00:00+00:00',198 'period': u'year',199 'end_at': u'2012-04-01T00:00:00+00:00',200 'dashboard_slug': 'bis-returns',201 'service_id': u'bis-annual-returns',202 "_id": encode_id('bis-returns', 'number_of_digital_transactions'),203 'type': u'seasonally-adjusted'204 }205]206sorn_dashboard_config = [{207 'slug': 'sorn'208}]209bis_returns_dashboard_config = [{210 'slug': 'bis-returns'211}]212quarterly_data_dashboard_config = [213 {214 'slug': 'quarterly-nonsense'215 },216 {...

Full Screen

Full Screen

urlshort.py

Source:urlshort.py Github

copy

Full Screen

...32 """33 with self.cursor() as cursor:34 cursor.execute('SELECT id FROM urls WHERE uri=?', (url,))35 if cursor.rowcount:36 return self.encode_id(cursor.fetchone()[0])37 cursor.execute("""INSERT INTO urls (uri, owner, created) VALUES (?, ?, now()) RETURNING id""", (url, self.anonyid, tags))38 urlid = cursor.fetchone()[0]39 for tag in tags:40 cursor.execute("""INSERT INTO tags (tag, url) VALUES (?, ?)""", (tag, urlid))41 return self.encode_id(urlid)42 def get_url(self, idcode):43 """retrieve a single URL from the database by id44 idcode: the encoded id of the URL.45 returns just the URL.46 """47 with self.cursor() as cursor:48 cursor.execute("""SELECT uri FROM urls WHERE id=?""", (self.decode_id(idcode),))49 if cursor.rowcount:50 return cursor.fetchone()[0]51 def get_urls_details(self):52 """Get the full record of all URLs from the database53 returns a list of lists containing [urlid, uri, creator, created timestamp, [tags]]54 """55 with self.cursor() as cursor:56 cursor.execute("""SELECT urls.id, urls.uri, users.name, urls.created, ARRAY(SELECT tag FROM tags WHERE url=urls.id) FROM urls, users WHERE urls.owner = users.id""")57 res = list()58 for url in cursor.fetchall():59 res.append(list(url))60 res[-1][0] = self.encode_id(res[-1][0])61 return res62 def get_url_details(self, idcode):63 """Get the full details of a particular URL by id.64 idcode: the encoded id of the URL.65 returns a list containinng [urlid, uri, creator, created timestamp, [tags]66 """67 with self.cursor() as cursor:68 cursor.execute("""SELECT urls.id, urls.uri, users.name, urls.created, ARRAY(SELECT tag FROM tags WHERE url=urls.id) FROM urls, users WHERE urls.id=? AND urls.owner = users.id""", (self.decode_id(idcode),))69 if cursor.rowcount:70 val = list(cursor.fetchone())71 val[0] = self.encode_id(val[0])72 return val73 def get_tags(self):74 """Get the list of unique tags in the database.75 returns a list of [tag, count]76 """77 with self.cursor() as cursor:78 cursor.execute("""SELECT tag, count(*) FROM tags GROUP BY tag""")79 return list(cursor.fetchall())80 def get_urls_by_tag(self, tag):81 """Get a list of URLs by tag.82 tag: a tag string.83 returns a list of [urlid, uri, creaator, created timestamp]84 """85 with self.cursor() as cursor:86 cursor.execute("""SELECT urls.id, urls.uri, users.name, urls.created FROM urls, users WHERE urls.id in (SELECT url FROM tags WHERE tag=?) AND urls.owner = users.id""", (tag,))87 val = list()88 for row in cursor.fetchall():89 val.append(list(row))90 val[-1][0] = self.encode_id(val[-1][0])91 return val92 def encode_id(self, idnr):93 """Encode a number using the shortener alphabet.94 idnr: a positive integer.95 retruns encoded string.96 """97 return baseconvert.baseN_encode(idnr, URLSHORT_ALPHABET)98 def decode_id(self, idcode):99 """Decode an encoded string into a number.100 idcode: an encoded string.101 returns a positive integer.102 """...

Full Screen

Full Screen

header.py

Source:header.py Github

copy

Full Screen

1def int_to_bytes(n, num_bytes):2 return n.to_bytes(num_bytes, 'big')3def int_from_bytes(bites):4 return int.from_bytes(bites, 'big')5class fountain_header:6 length = 67 def __init__(self, encode_id, total_size=None, chunk_id=None):8 if total_size is None:9 self.encode_id, self.total_size, self.chunk_id = self.from_encoded(encode_id)10 else:11 self.encode_id = encode_id12 self.total_size = total_size13 self.chunk_id = chunk_id14 def __bytes__(self):15 eid = self.encode_id + ((self.total_size & 0x1000000) >> 17)16 sz = self.total_size & 0xFFFFFF17 return int_to_bytes(eid, 1) + int_to_bytes(sz, 3) + int_to_bytes(self.chunk_id, 2)18 @classmethod19 def from_encoded(cls, encoded_bytes):20 encode_id = int_from_bytes(encoded_bytes[0:1])21 total_size = int_from_bytes(encoded_bytes[1:4])22 chunk_id = int_from_bytes(encoded_bytes[4:6])23 total_size = total_size | ((encode_id & 0x80) << 17)24 encode_id = encode_id & 0x7F...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run devtools-proxy automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful