set user agent string.
This commit is contained in:
parent
37a4cedc4d
commit
d983c452de
@ -0,0 +1,3 @@
|
|||||||
|
from mdrsclient.__version__ import __version__
|
||||||
|
|
||||||
|
__all__ = ["__version__"]
|
@ -21,7 +21,7 @@ from mdrsclient.exceptions import MDRSException
|
|||||||
|
|
||||||
|
|
||||||
def main() -> None:
|
def main() -> None:
|
||||||
description = """This is a command-line program to up files."""
|
description = """This is a command-line program for up- and downloading files to and from MDRS based repository."""
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter)
|
parser = argparse.ArgumentParser(description=description, formatter_class=argparse.RawDescriptionHelpFormatter)
|
||||||
parsers = parser.add_subparsers(title="subcommands")
|
parsers = parser.add_subparsers(title="subcommands")
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
|
import platform
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
from requests import Response, Session
|
from requests import Response, Session
|
||||||
|
|
||||||
|
from mdrsclient.__version__ import __version__
|
||||||
from mdrsclient.cache import CacheFile
|
from mdrsclient.cache import CacheFile
|
||||||
from mdrsclient.exceptions import MissingConfigurationException
|
from mdrsclient.exceptions import MissingConfigurationException
|
||||||
from mdrsclient.models import Laboratories, Token, User
|
from mdrsclient.models import Laboratories, Token, User
|
||||||
@ -74,6 +76,11 @@ class MDRSConnection:
|
|||||||
return "/".join(parts)
|
return "/".join(parts)
|
||||||
|
|
||||||
def __prepare_headers(self) -> None:
|
def __prepare_headers(self) -> None:
|
||||||
self.session.headers.update({"accept": "application/json"})
|
self.session.headers.update(
|
||||||
|
{
|
||||||
|
"User-Agent": f"MdrsClient/{__version__} (Python {platform.python_version()} - {platform.platform()})",
|
||||||
|
"Accept": "application/json",
|
||||||
|
}
|
||||||
|
)
|
||||||
if self.token is not None:
|
if self.token is not None:
|
||||||
self.session.headers.update({"Authorization": f"Bearer {self.token.access}"})
|
self.session.headers.update({"Authorization": f"Bearer {self.token.access}"})
|
||||||
|
@ -20,5 +20,5 @@ class FileLock:
|
|||||||
def unlock(file: IO[Any]) -> None:
|
def unlock(file: IO[Any]) -> None:
|
||||||
if os.name == "nt":
|
if os.name == "nt":
|
||||||
msvcrt.locking(file.fileno(), msvcrt.LK_UNLCK, 1)
|
msvcrt.locking(file.fileno(), msvcrt.LK_UNLCK, 1)
|
||||||
else:
|
elif os.name == "posix":
|
||||||
fcntl.flock(file.fileno(), fcntl.LOCK_UN)
|
fcntl.flock(file.fileno(), fcntl.LOCK_UN)
|
||||||
|
Loading…
Reference in New Issue
Block a user