-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from ess-dmsc/service
extracted server for service.
- Loading branch information
Showing
9 changed files
with
221 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import argparse | ||
import logging | ||
import os | ||
import sys | ||
import time | ||
|
||
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.realpath(__file__)))) | ||
from yuos_query import YuosServer | ||
|
||
|
||
def main(url, instrument, cache_filepath, update_interval=3200): | ||
while True: | ||
try: | ||
YuosServer.create( | ||
url, os.environ.get("YUOS_TOKEN"), instrument, cache_filepath | ||
).update_cache() | ||
logging.info("updated cache") | ||
time.sleep(update_interval) | ||
except RuntimeError as error: | ||
logging.error(f"failed to update cache {error}") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
|
||
required_args = parser.add_argument_group("required arguments") | ||
required_args.add_argument( | ||
"-u", | ||
"--url", | ||
type=str, | ||
help="the URL for the proposal system", | ||
required=True, | ||
) | ||
|
||
required_args.add_argument( | ||
"-i", "--instrument", type=str, help="the instrument name", required=True | ||
) | ||
|
||
parser.add_argument( | ||
"-c", | ||
"--cache-filepath", | ||
type=str, | ||
help="where to write the data", | ||
required=True, | ||
) | ||
|
||
parser.add_argument( | ||
"-l", | ||
"--log-level", | ||
type=int, | ||
default=3, | ||
help="sets the logging level: debug=1, info=2, warning=3, error=4, critical=5.", | ||
) | ||
|
||
args = parser.parse_args() | ||
|
||
if 1 <= args.log_level <= 5: | ||
logging.basicConfig( | ||
format="%(asctime)s - %(message)s", level=args.log_level * 10 | ||
) | ||
else: | ||
logging.basicConfig(format="%(asctime)s - %(message)s", level=logging.INFO) | ||
|
||
main( | ||
args.url, | ||
args.instrument, | ||
args.cache_filepath, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from yuos_query.version import version | ||
from yuos_query.yuos_client import YuosCacheClient, YuosServer # noqa: F401 | ||
|
||
__version__ = version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
version = "0.1.17" | ||
version = "0.1.18" |
Oops, something went wrong.