Lockfile custom command, fixup minor things.
authorScott Gasch <[email protected]>
Thu, 29 Jul 2021 16:11:05 +0000 (09:11 -0700)
committerScott Gasch <[email protected]>
Thu, 29 Jul 2021 16:11:05 +0000 (09:11 -0700)
decorator_utils.py
lockfile.py
type/centcount.py
type/money.py

index 0d5b3e3213c393e8843c5f1abb677d3e3e36cdb4..76faec6f7be2e8d52f3ed9c7e05e1dc6048d666b 100644 (file)
@@ -340,7 +340,7 @@ def _target(queue, function, *args, **kwargs):
     """
     try:
         queue.put((True, function(*args, **kwargs)))
-    except:
+    except Exception:
         queue.put((False, sys.exc_info()[1]))
 
 
index ee8c2559606b0fc9488d3c2bc5ed772ec70254a0..770beaa9f97e3525f55b938e09a972e3b67e0e5a 100644 (file)
@@ -37,9 +37,11 @@ class LockFile(object):
             *,
             do_signal_cleanup: bool = True,
             expiration_timestamp: Optional[float] = None,
+            override_command: Optional[str] = None,
     ) -> None:
         self.is_locked = False
         self.lockfile = lockfile_path
+        self.override_command = override_command
         if do_signal_cleanup:
             signal.signal(signal.SIGINT, self._signal)
             signal.signal(signal.SIGTERM, self._signal)
@@ -117,10 +119,14 @@ class LockFile(object):
             self.release()
 
     def _get_lockfile_contents(self) -> str:
+        if self.override_command:
+            cmd = self.override_command
+        else:
+            cmd = ' '.join(sys.argv)
         contents = LockFileContents(
             pid = os.getpid(),
-            commandline = ' '.join(sys.argv),
-            expiration_timestamp = self.expiration_timestamp
+            cmd,
+            expiration_timestamp = self.expiration_timestamp,
         )
         return json.dumps(contents.__dict__)
 
index 4181721bbc0d4ab7efe38608b821faa26ecf5bae..ce18975167573a236cf2a9ee3f04604333d9c82d 100644 (file)
@@ -210,7 +210,7 @@ class CentCount(object):
                     centcount = int(float(chunk) * 100.0)
                 elif CentCount.CURRENCY_RE.match(chunk) is not None:
                     currency = chunk
-        except:
+        except Exception:
             pass
         if centcount is not None and currency is not None:
             return (centcount, currency)
index c77a9389391201c47528bcc1f87bbf7e79134e02..290c2c86f91a7a6da652b21e670d2579c51ba6c0 100644 (file)
@@ -17,7 +17,7 @@ class Money(object):
 
     def __init__ (
             self,
-            amount: Decimal = Decimal("0.0"),
+            amount: Decimal = Decimal("0"),
             currency: str = 'USD',
             *,
             strict_mode = False
@@ -211,7 +211,7 @@ class Money(object):
                     amount = Decimal(chunk)
                 elif Money.CURRENCY_RE.match(chunk) is not None:
                     currency = chunk
-        except:
+        except Exception:
             pass
         if amount is not None and currency is not None:
             return (amount, currency)