summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2021-07-29 09:11:05 -0700
committerScott Gasch <[email protected]>2021-07-29 09:11:05 -0700
commita08ca309cb5bd7971210a9247a38c9bbe376a6e6 (patch)
tree879e0ee5403d5ede0658db5ed6e4705c86208f9c
parent4faa994d32223c8d560d9dad0ca90a3f7eb10d6a (diff)
Lockfile custom command, fixup minor things.
-rw-r--r--decorator_utils.py2
-rw-r--r--lockfile.py10
-rw-r--r--type/centcount.py2
-rw-r--r--type/money.py4
4 files changed, 12 insertions, 6 deletions
diff --git a/decorator_utils.py b/decorator_utils.py
index 0d5b3e3..76faec6 100644
--- a/decorator_utils.py
+++ b/decorator_utils.py
@@ -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]))
diff --git a/lockfile.py b/lockfile.py
index ee8c255..770beaa 100644
--- a/lockfile.py
+++ b/lockfile.py
@@ -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__)
diff --git a/type/centcount.py b/type/centcount.py
index 4181721..ce18975 100644
--- a/type/centcount.py
+++ b/type/centcount.py
@@ -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)
diff --git a/type/money.py b/type/money.py
index c77a938..290c2c8 100644
--- a/type/money.py
+++ b/type/money.py
@@ -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)