Skip to content

Commit

Permalink
Merge pull request #23 from ENCODE-DCC/dev
Browse files Browse the repository at this point in the history
v0.2.5
  • Loading branch information
leepc12 authored Apr 20, 2021
2 parents cf72735 + 495bffd commit 827ff60
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
2 changes: 1 addition & 1 deletion autouri/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from .s3uri import S3URI

__all__ = ["AbsPath", "AutoURI", "URIBase", "GCSURI", "HTTPURL", "S3URI"]
__version__ = "0.2.4"
__version__ = "0.2.5"
16 changes: 15 additions & 1 deletion autouri/gcsuri.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import requests
from filelock import BaseFileLock
from filelock import Timeout as FileLockTimeout
from google.api_core.exceptions import (
Forbidden,
GatewayTimeout,
Expand Down Expand Up @@ -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.
Expand Down
34 changes: 33 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -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.4",
version=find_meta("version"),
python_requires=">=3.6",
scripts=["bin/autouri"],
author="Jin wook Lee",
Expand Down

0 comments on commit 827ff60

Please sign in to comment.