From 93b8a6d787f751f260f7ce5a6592f7fcf49f41e9 Mon Sep 17 00:00:00 2001 From: Jin Lee Date: Mon, 12 Apr 2021 14:19:50 -0700 Subject: [PATCH 1/3] added help to delete lock file --- autouri/gcsuri.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/autouri/gcsuri.py b/autouri/gcsuri.py index af9f41a..677950e 100644 --- a/autouri/gcsuri.py +++ b/autouri/gcsuri.py @@ -14,6 +14,7 @@ import requests from filelock import BaseFileLock +from filelock import Timeout as FileLockTimeout from google.api_core.exceptions import ( Forbidden, GatewayTimeout, @@ -98,7 +99,20 @@ def __init__( def acquire(self, timeout=None, poll_intervall=5.0): """Use self._poll_interval instead of poll_intervall in args """ - super().acquire(timeout=timeout, poll_intervall=self._poll_interval) + try: + super().acquire(timeout=timeout, poll_intervall=self._poll_interval) + except FileLockTimeout: + logger.error( + "Filelock timed out. Is there any other process holding the file? " + "Or this can happen when autouri was forcefully killed while holding a file. " + "e.g. pressing Ctrl+C two many times or killed by the system with SIGKILL. " + "If there is no other process holding the file " + "then please manually release/delete the lock file with gsutil. " + "Use the following command lines to delete the lock file.\n\n" + "gsutil retention temp release {lock_file}\n" + "gsutil rm {lock_file}\n".format(lock_file=self._lock_file) + ) + raise def _acquire(self): """Try to acquire a lock. From 15e695f32c6acebdad673e20d57630aa873f2bdd Mon Sep 17 00:00:00 2001 From: Jin Lee Date: Mon, 12 Apr 2021 14:20:10 -0700 Subject: [PATCH 2/3] bump version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index fdf1dea..b82b8f1 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="autouri", - version="0.2.4", + version="0.2.5", python_requires=">=3.6", scripts=["bin/autouri"], author="Jin wook Lee", From 495bffd069459b9fa76e54cc31b6c1f5e81b2c90 Mon Sep 17 00:00:00 2001 From: Jin Lee Date: Tue, 20 Apr 2021 11:15:30 -0700 Subject: [PATCH 3/3] bump ver, read version from init --- autouri/__init__.py | 2 +- setup.py | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/autouri/__init__.py b/autouri/__init__.py index bba6d0c..cc19d10 100644 --- a/autouri/__init__.py +++ b/autouri/__init__.py @@ -5,4 +5,4 @@ from .s3uri import S3URI __all__ = ["AbsPath", "AutoURI", "URIBase", "GCSURI", "HTTPURL", "S3URI"] -__version__ = "0.2.4" +__version__ = "0.2.5" diff --git a/setup.py b/setup.py index b82b8f1..289e1f5 100644 --- a/setup.py +++ b/setup.py @@ -1,11 +1,43 @@ +import os +import re +from pathlib import Path + import setuptools +META_PATH = Path("autouri", "__init__.py") +HERE = os.path.abspath(os.path.dirname(__file__)) + + +def read(*parts): + """ + Build an absolute path from *parts* and and return the contents of the + resulting file. Assume UTF-8 encoding. + """ + with Path(HERE, *parts).open(encoding="utf-8") as f: + return f.read() + + +META_FILE = read(META_PATH) + + +def find_meta(meta): + """ + Extract __*meta*__ from META_FILE. + """ + meta_match = re.search( + r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), META_FILE, re.M + ) + if meta_match: + return meta_match.group(1) + raise + + with open("README.md", "r") as fh: long_description = fh.read() setuptools.setup( name="autouri", - version="0.2.5", + version=find_meta("version"), python_requires=">=3.6", scripts=["bin/autouri"], author="Jin wook Lee",