summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorMichael Opdenacker <michael.opdenacker@bootlin.com>2024-04-12 11:02:24 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-04-14 06:31:45 +0100
commit4b1ef692a9db79321be765c8e38de953ac52a7e1 (patch)
tree4541a7a253ac53623ff45f2efa92c2ffc9b94f07 /bitbake
parent8d78b5f9c5cee19ed98e65577bf9e3a325d859b3 (diff)
downloadpoky-4b1ef692a9db79321be765c8e38de953ac52a7e1.tar.gz
bitbake: prserv: use double quotes by default
To aligh with the hashserv code (Bitbake rev: 7a6999750791659eaffe49aabfbfba9f37f51913) Signed-off-by: Michael Opdenacker <michael.opdenacker@bootlin.com> Cc: Joshua Watt <JPEWhacker@gmail.com> Cc: Tim Orling <ticotimo@gmail.com> Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rwxr-xr-xbitbake/bin/bitbake-prserv4
-rw-r--r--bitbake/lib/prserv/__init__.py4
-rw-r--r--bitbake/lib/prserv/client.py20
-rw-r--r--bitbake/lib/prserv/db.py32
-rw-r--r--bitbake/lib/prserv/serv.py64
5 files changed, 62 insertions, 62 deletions
diff --git a/bitbake/bin/bitbake-prserv b/bitbake/bin/bitbake-prserv
index 5be42f3ce5..8c3808fb20 100755
--- a/bitbake/bin/bitbake-prserv
+++ b/bitbake/bin/bitbake-prserv
@@ -11,14 +11,14 @@ import optparse
11import warnings 11import warnings
12warnings.simplefilter("default") 12warnings.simplefilter("default")
13 13
14sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)),'lib')) 14sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), "lib"))
15 15
16import prserv 16import prserv
17import prserv.serv 17import prserv.serv
18 18
19__version__="1.0.0" 19__version__="1.0.0"
20 20
21PRHOST_DEFAULT='0.0.0.0' 21PRHOST_DEFAULT="0.0.0.0"
22PRPORT_DEFAULT=8585 22PRPORT_DEFAULT=8585
23 23
24def main(): 24def main():
diff --git a/bitbake/lib/prserv/__init__.py b/bitbake/lib/prserv/__init__.py
index 38ced818ad..5790a8db1e 100644
--- a/bitbake/lib/prserv/__init__.py
+++ b/bitbake/lib/prserv/__init__.py
@@ -12,8 +12,8 @@ import sys,logging
12def init_logger(logfile, loglevel): 12def init_logger(logfile, loglevel):
13 numeric_level = getattr(logging, loglevel.upper(), None) 13 numeric_level = getattr(logging, loglevel.upper(), None)
14 if not isinstance(numeric_level, int): 14 if not isinstance(numeric_level, int):
15 raise ValueError('Invalid log level: %s' % loglevel) 15 raise ValueError("Invalid log level: %s" % loglevel)
16 FORMAT = '%(asctime)-15s %(message)s' 16 FORMAT = "%(asctime)-15s %(message)s"
17 logging.basicConfig(level=numeric_level, filename=logfile, format=FORMAT) 17 logging.basicConfig(level=numeric_level, filename=logfile, format=FORMAT)
18 18
19class NotFoundError(Exception): 19class NotFoundError(Exception):
diff --git a/bitbake/lib/prserv/client.py b/bitbake/lib/prserv/client.py
index 6b81356fac..7bc5188c53 100644
--- a/bitbake/lib/prserv/client.py
+++ b/bitbake/lib/prserv/client.py
@@ -11,40 +11,40 @@ logger = logging.getLogger("BitBake.PRserv")
11 11
12class PRAsyncClient(bb.asyncrpc.AsyncClient): 12class PRAsyncClient(bb.asyncrpc.AsyncClient):
13 def __init__(self): 13 def __init__(self):
14 super().__init__('PRSERVICE', '1.0', logger) 14 super().__init__("PRSERVICE", "1.0", logger)
15 15
16 async def getPR(self, version, pkgarch, checksum): 16 async def getPR(self, version, pkgarch, checksum):
17 response = await self.invoke( 17 response = await self.invoke(
18 {'get-pr': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum}} 18 {"get-pr": {"version": version, "pkgarch": pkgarch, "checksum": checksum}}
19 ) 19 )
20 if response: 20 if response:
21 return response['value'] 21 return response["value"]
22 22
23 async def importone(self, version, pkgarch, checksum, value): 23 async def importone(self, version, pkgarch, checksum, value):
24 response = await self.invoke( 24 response = await self.invoke(
25 {'import-one': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum, 'value': value}} 25 {"import-one": {"version": version, "pkgarch": pkgarch, "checksum": checksum, "value": value}}
26 ) 26 )
27 if response: 27 if response:
28 return response['value'] 28 return response["value"]
29 29
30 async def export(self, version, pkgarch, checksum, colinfo): 30 async def export(self, version, pkgarch, checksum, colinfo):
31 response = await self.invoke( 31 response = await self.invoke(
32 {'export': {'version': version, 'pkgarch': pkgarch, 'checksum': checksum, 'colinfo': colinfo}} 32 {"export": {"version": version, "pkgarch": pkgarch, "checksum": checksum, "colinfo": colinfo}}
33 ) 33 )
34 if response: 34 if response:
35 return (response['metainfo'], response['datainfo']) 35 return (response["metainfo"], response["datainfo"])
36 36
37 async def is_readonly(self): 37 async def is_readonly(self):
38 response = await self.invoke( 38 response = await self.invoke(
39 {'is-readonly': {}} 39 {"is-readonly": {}}
40 ) 40 )
41 if response: 41 if response:
42 return response['readonly'] 42 return response["readonly"]
43 43
44class PRClient(bb.asyncrpc.Client): 44class PRClient(bb.asyncrpc.Client):
45 def __init__(self): 45 def __init__(self):
46 super().__init__() 46 super().__init__()
47 self._add_methods('getPR', 'importone', 'export', 'is_readonly') 47 self._add_methods("getPR", "importone", "export", "is_readonly")
48 48
49 def _get_async_client(self): 49 def _get_async_client(self):
50 return PRAsyncClient() 50 return PRAsyncClient()
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py
index b4bda7078c..0859cf4f2c 100644
--- a/bitbake/lib/prserv/db.py
+++ b/bitbake/lib/prserv/db.py
@@ -64,7 +64,7 @@ class PRTable(object):
64 try: 64 try:
65 return self.conn.execute(*query) 65 return self.conn.execute(*query)
66 except sqlite3.OperationalError as exc: 66 except sqlite3.OperationalError as exc:
67 if 'is locked' in str(exc) and end > time.time(): 67 if "is locked" in str(exc) and end > time.time():
68 continue 68 continue
69 raise exc 69 raise exc
70 70
@@ -220,18 +220,18 @@ class PRTable(object):
220 metainfo = {} 220 metainfo = {}
221 #column info 221 #column info
222 if colinfo: 222 if colinfo:
223 metainfo['tbl_name'] = self.table 223 metainfo["tbl_name"] = self.table
224 metainfo['core_ver'] = prserv.__version__ 224 metainfo["core_ver"] = prserv.__version__
225 metainfo['col_info'] = [] 225 metainfo["col_info"] = []
226 data = self._execute("PRAGMA table_info(%s);" % self.table) 226 data = self._execute("PRAGMA table_info(%s);" % self.table)
227 for row in data: 227 for row in data:
228 col = {} 228 col = {}
229 col['name'] = row['name'] 229 col["name"] = row["name"]
230 col['type'] = row['type'] 230 col["type"] = row["type"]
231 col['notnull'] = row['notnull'] 231 col["notnull"] = row["notnull"]
232 col['dflt_value'] = row['dflt_value'] 232 col["dflt_value"] = row["dflt_value"]
233 col['pk'] = row['pk'] 233 col["pk"] = row["pk"]
234 metainfo['col_info'].append(col) 234 metainfo["col_info"].append(col)
235 235
236 #data info 236 #data info
237 datainfo = [] 237 datainfo = []
@@ -261,12 +261,12 @@ class PRTable(object):
261 else: 261 else:
262 data = self._execute(sqlstmt) 262 data = self._execute(sqlstmt)
263 for row in data: 263 for row in data:
264 if row['version']: 264 if row["version"]:
265 col = {} 265 col = {}
266 col['version'] = row['version'] 266 col["version"] = row["version"]
267 col['pkgarch'] = row['pkgarch'] 267 col["pkgarch"] = row["pkgarch"]
268 col['checksum'] = row['checksum'] 268 col["checksum"] = row["checksum"]
269 col['value'] = row['value'] 269 col["value"] = row["value"]
270 datainfo.append(col) 270 datainfo.append(col)
271 return (metainfo, datainfo) 271 return (metainfo, datainfo)
272 272
@@ -275,7 +275,7 @@ class PRTable(object):
275 for line in self.conn.iterdump(): 275 for line in self.conn.iterdump():
276 writeCount = writeCount + len(line) + 1 276 writeCount = writeCount + len(line) + 1
277 fd.write(line) 277 fd.write(line)
278 fd.write('\n') 278 fd.write("\n")
279 return writeCount 279 return writeCount
280 280
281class PRData(object): 281class PRData(object):
diff --git a/bitbake/lib/prserv/serv.py b/bitbake/lib/prserv/serv.py
index 28af636966..49f5ae36db 100644
--- a/bitbake/lib/prserv/serv.py
+++ b/bitbake/lib/prserv/serv.py
@@ -21,14 +21,14 @@ singleton = None
21 21
22class PRServerClient(bb.asyncrpc.AsyncServerConnection): 22class PRServerClient(bb.asyncrpc.AsyncServerConnection):
23 def __init__(self, socket, server): 23 def __init__(self, socket, server):
24 super().__init__(socket, 'PRSERVICE', server.logger) 24 super().__init__(socket, "PRSERVICE", server.logger)
25 self.server = server 25 self.server = server
26 26
27 self.handlers.update({ 27 self.handlers.update({
28 'get-pr': self.handle_get_pr, 28 "get-pr": self.handle_get_pr,
29 'import-one': self.handle_import_one, 29 "import-one": self.handle_import_one,
30 'export': self.handle_export, 30 "export": self.handle_export,
31 'is-readonly': self.handle_is_readonly, 31 "is-readonly": self.handle_is_readonly,
32 }) 32 })
33 33
34 def validate_proto_version(self): 34 def validate_proto_version(self):
@@ -44,14 +44,14 @@ class PRServerClient(bb.asyncrpc.AsyncServerConnection):
44 self.server.table.sync_if_dirty() 44 self.server.table.sync_if_dirty()
45 45
46 async def handle_get_pr(self, request): 46 async def handle_get_pr(self, request):
47 version = request['version'] 47 version = request["version"]
48 pkgarch = request['pkgarch'] 48 pkgarch = request["pkgarch"]
49 checksum = request['checksum'] 49 checksum = request["checksum"]
50 50
51 response = None 51 response = None
52 try: 52 try:
53 value = self.server.table.getValue(version, pkgarch, checksum) 53 value = self.server.table.getValue(version, pkgarch, checksum)
54 response = {'value': value} 54 response = {"value": value}
55 except prserv.NotFoundError: 55 except prserv.NotFoundError:
56 logger.error("can not find value for (%s, %s)",version, checksum) 56 logger.error("can not find value for (%s, %s)",version, checksum)
57 except sqlite3.Error as exc: 57 except sqlite3.Error as exc:
@@ -62,22 +62,22 @@ class PRServerClient(bb.asyncrpc.AsyncServerConnection):
62 async def handle_import_one(self, request): 62 async def handle_import_one(self, request):
63 response = None 63 response = None
64 if not self.server.read_only: 64 if not self.server.read_only:
65 version = request['version'] 65 version = request["version"]
66 pkgarch = request['pkgarch'] 66 pkgarch = request["pkgarch"]
67 checksum = request['checksum'] 67 checksum = request["checksum"]
68 value = request['value'] 68 value = request["value"]
69 69
70 value = self.server.table.importone(version, pkgarch, checksum, value) 70 value = self.server.table.importone(version, pkgarch, checksum, value)
71 if value is not None: 71 if value is not None:
72 response = {'value': value} 72 response = {"value": value}
73 73
74 return response 74 return response
75 75
76 async def handle_export(self, request): 76 async def handle_export(self, request):
77 version = request['version'] 77 version = request["version"]
78 pkgarch = request['pkgarch'] 78 pkgarch = request["pkgarch"]
79 checksum = request['checksum'] 79 checksum = request["checksum"]
80 colinfo = request['colinfo'] 80 colinfo = request["colinfo"]
81 81
82 try: 82 try:
83 (metainfo, datainfo) = self.server.table.export(version, pkgarch, checksum, colinfo) 83 (metainfo, datainfo) = self.server.table.export(version, pkgarch, checksum, colinfo)
@@ -85,10 +85,10 @@ class PRServerClient(bb.asyncrpc.AsyncServerConnection):
85 logger.error(str(exc)) 85 logger.error(str(exc))
86 metainfo = datainfo = None 86 metainfo = datainfo = None
87 87
88 return {'metainfo': metainfo, 'datainfo': datainfo} 88 return {"metainfo": metainfo, "datainfo": datainfo}
89 89
90 async def handle_is_readonly(self, request): 90 async def handle_is_readonly(self, request):
91 return {'readonly': self.server.read_only} 91 return {"readonly": self.server.read_only}
92 92
93class PRServer(bb.asyncrpc.AsyncServer): 93class PRServer(bb.asyncrpc.AsyncServer):
94 def __init__(self, dbfile, read_only=False): 94 def __init__(self, dbfile, read_only=False):
@@ -135,7 +135,7 @@ class PRServSingleton(object):
135 if not self.prserv.address: 135 if not self.prserv.address:
136 raise PRServiceConfigError 136 raise PRServiceConfigError
137 if not self.port: 137 if not self.port:
138 self.port = int(self.prserv.address.rsplit(':', 1)[1]) 138 self.port = int(self.prserv.address.rsplit(":", 1)[1])
139 139
140def run_as_daemon(func, pidfile, logfile): 140def run_as_daemon(func, pidfile, logfile):
141 """ 141 """
@@ -171,12 +171,12 @@ def run_as_daemon(func, pidfile, logfile):
171 # stdout/stderr or it could be 'real' unix fd forking where we need 171 # stdout/stderr or it could be 'real' unix fd forking where we need
172 # to physically close the fds to prevent the program launching us from 172 # to physically close the fds to prevent the program launching us from
173 # potentially hanging on a pipe. Handle both cases. 173 # potentially hanging on a pipe. Handle both cases.
174 si = open('/dev/null', 'r') 174 si = open("/dev/null", "r")
175 try: 175 try:
176 os.dup2(si.fileno(),sys.stdin.fileno()) 176 os.dup2(si.fileno(),sys.stdin.fileno())
177 except (AttributeError, io.UnsupportedOperation): 177 except (AttributeError, io.UnsupportedOperation):
178 sys.stdin = si 178 sys.stdin = si
179 so = open(logfile, 'a+') 179 so = open(logfile, "a+")
180 try: 180 try:
181 os.dup2(so.fileno(),sys.stdout.fileno()) 181 os.dup2(so.fileno(),sys.stdout.fileno())
182 except (AttributeError, io.UnsupportedOperation): 182 except (AttributeError, io.UnsupportedOperation):
@@ -200,7 +200,7 @@ def run_as_daemon(func, pidfile, logfile):
200 200
201 # write pidfile 201 # write pidfile
202 pid = str(os.getpid()) 202 pid = str(os.getpid())
203 with open(pidfile, 'w') as pf: 203 with open(pidfile, "w") as pf:
204 pf.write("%s\n" % pid) 204 pf.write("%s\n" % pid)
205 205
206 func() 206 func()
@@ -245,12 +245,12 @@ def stop_daemon(host, port):
245 # so at least advise the user which ports the corresponding server is listening 245 # so at least advise the user which ports the corresponding server is listening
246 ports = [] 246 ports = []
247 portstr = "" 247 portstr = ""
248 for pf in glob.glob(PIDPREFIX % (ip,'*')): 248 for pf in glob.glob(PIDPREFIX % (ip, "*")):
249 bn = os.path.basename(pf) 249 bn = os.path.basename(pf)
250 root, _ = os.path.splitext(bn) 250 root, _ = os.path.splitext(bn)
251 ports.append(root.split('_')[-1]) 251 ports.append(root.split("_")[-1])
252 if len(ports): 252 if len(ports):
253 portstr = "Wrong port? Other ports listening at %s: %s" % (host, ' '.join(ports)) 253 portstr = "Wrong port? Other ports listening at %s: %s" % (host, " ".join(ports))
254 254
255 sys.stderr.write("pidfile %s does not exist. Daemon not running? %s\n" 255 sys.stderr.write("pidfile %s does not exist. Daemon not running? %s\n"
256 % (pidfile,portstr)) 256 % (pidfile,portstr))
@@ -284,7 +284,7 @@ def is_running(pid):
284 return True 284 return True
285 285
286def is_local_special(host, port): 286def is_local_special(host, port):
287 if (host == 'localhost' or host == '127.0.0.1') and not port: 287 if (host == "localhost" or host == "127.0.0.1") and not port:
288 return True 288 return True
289 else: 289 else:
290 return False 290 return False
@@ -295,7 +295,7 @@ class PRServiceConfigError(Exception):
295def auto_start(d): 295def auto_start(d):
296 global singleton 296 global singleton
297 297
298 host_params = list(filter(None, (d.getVar('PRSERV_HOST') or '').split(':'))) 298 host_params = list(filter(None, (d.getVar("PRSERV_HOST") or "").split(":")))
299 if not host_params: 299 if not host_params:
300 # Shutdown any existing PR Server 300 # Shutdown any existing PR Server
301 auto_shutdown() 301 auto_shutdown()
@@ -304,7 +304,7 @@ def auto_start(d):
304 if len(host_params) != 2: 304 if len(host_params) != 2:
305 # Shutdown any existing PR Server 305 # Shutdown any existing PR Server
306 auto_shutdown() 306 auto_shutdown()
307 logger.critical('\n'.join(['PRSERV_HOST: incorrect format', 307 logger.critical("\n".join(["PRSERV_HOST: incorrect format",
308 'Usage: PRSERV_HOST = "<hostname>:<port>"'])) 308 'Usage: PRSERV_HOST = "<hostname>:<port>"']))
309 raise PRServiceConfigError 309 raise PRServiceConfigError
310 310
@@ -357,8 +357,8 @@ def connect(host, port):
357 357
358 global singleton 358 global singleton
359 359
360 if host.strip().lower() == 'localhost' and not port: 360 if host.strip().lower() == "localhost" and not port:
361 host = 'localhost' 361 host = "localhost"
362 port = singleton.port 362 port = singleton.port
363 363
364 conn = client.PRClient() 364 conn = client.PRClient()