fix/get new tomo ID
This commit is contained in:
@@ -253,7 +253,7 @@ class TomoIDManager:
|
||||
OMNY_URL = "https://v1p0zyg2w9n2k9c1.myfritz.net/samples/newmeasurement.php"
|
||||
OMNY_USER = ""
|
||||
OMNY_PASSWORD = ""
|
||||
TMP_FILE = "/tmp/currsamplesnr.txt"
|
||||
TMP_FILE = "~/currsamplesnr.txt"
|
||||
|
||||
def register(
|
||||
self,
|
||||
@@ -295,9 +295,22 @@ class TomoIDManager:
|
||||
# shell=True,
|
||||
# )
|
||||
#print(url)
|
||||
subprocess.run(
|
||||
f"wget -q -O {self.TMP_FILE} '{url}'",
|
||||
tmp_file = os.path.expanduser(self.TMP_FILE)
|
||||
result = subprocess.run(
|
||||
f"wget -q -O {tmp_file} '{url}'",
|
||||
shell=True,
|
||||
)
|
||||
with open(self.TMP_FILE) as f:
|
||||
return int(f.read())
|
||||
if result.returncode != 0:
|
||||
raise OMNYToolsError(
|
||||
f"wget failed (exit code {result.returncode}) fetching tomo ID from {self.OMNY_URL}"
|
||||
)
|
||||
try:
|
||||
with open(tmp_file) as f:
|
||||
content = f.read().strip()
|
||||
return int(content)
|
||||
except FileNotFoundError as exc:
|
||||
raise OMNYToolsError(f"wget did not produce output file {tmp_file}") from exc
|
||||
except ValueError as exc:
|
||||
raise OMNYToolsError(
|
||||
f"Unexpected response from tomo ID server, got: {content!r}"
|
||||
) from exc
|
||||
|
||||
Reference in New Issue
Block a user