Skip to content

Commit 88b5174

Browse files
committed
hack for mink.py to run it inspite of blocked group policy
1 parent ddd4356 commit 88b5174

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

.gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
*.pyc
33
*.xml
44
.coverage
5-
credentials.py
65
.settings/*
76
.project
87
.pydvproject
@@ -11,6 +10,5 @@ bak/*
1110
dist/*
1211
build/*
1312
sdata/*
14-
sdata2/*
1513
test/sdata/*
1614
src/MpApi_M3.egg-info/*

src/mpapi/chunky.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def _relatedItems(
315315
# binary_file.write(r.content)
316316
return etree.fromstring(r.content, ETparser)
317317

318-
def _savedQuery(self, *, Type: str = "Object", ID: int, offset: int = 0):
318+
def _savedQuery(self, *, Type: str = "Object", ID: int, offset: int = 0) -> Module:
319319
return self.api.runSavedQuery2(
320320
Type=Type, ID=ID, offset=offset, limit=self.chunkSize
321321
)

src/mpapi/getAttachments.py

+13-17
Original file line numberDiff line numberDiff line change
@@ -83,23 +83,23 @@ def __init__(
8383
self.force = force
8484
# default for saving new request
8585
# if we're not using a cache
86-
cache_fn = f"mul_{self.conf['type']}{self.conf['id']}.xml"
86+
cache_fn = f"{self.conf['type']}{self.conf['id']}.xml"
8787

8888
if cache:
8989
print("* loading cached response")
90-
self.cache = Module(file=cache)
90+
self.data = Module(file=cache)
9191
else:
9292
print("* launching new search")
93-
m = self.get_multimedia_for_job()
94-
m.toFile(path=cache_fn)
95-
self.cache = m
93+
self.data = self.get_multimedia_for_job()
94+
self.data.toFile(path=cache_fn)
9695

9796
if self.conf["attachments"]["name"] == "Cornelia":
9897
# in this mode we need object data...
99-
self.cache += self._init_objData()
100-
self.cache.toFile(path=cache)
98+
self.data += self._init_objData()
99+
if not cache:
100+
self.data.toFile(path=cache_fn)
101101

102-
self.process_response(data=self.cache)
102+
self.process_response(data=self.data)
103103

104104
def process_response(self, *, data: Module) -> None:
105105
print("* processing response")
@@ -248,7 +248,7 @@ def _get_single_attachment(self, *, item, ID: int, out_dir: Path) -> None:
248248

249249
match self.conf["attachments"]["name"]:
250250
case "Cornelia":
251-
res = self.cache.xpath(f"""
251+
res = self.data.xpath(f"""
252252
/m:application/m:modules/m:module[
253253
@name = 'Object'
254254
]/m:moduleItem/m:moduleReference[
@@ -296,21 +296,17 @@ def _get_out_dir(self) -> Path:
296296
return out_dir
297297

298298
def _init_objData(self) -> None:
299-
obj_fn = Path(f"obj_{self.conf['type']}{self.conf['id']}.xml")
300-
if self.cache:
301-
if self.cache.actualSize(module="Object") > 0:
299+
# obj_fn = Path(f"obj_{self.conf['type']}{self.conf['id']}.xml")
300+
if self.data:
301+
if self.data.actualSize(module="Object") > 0:
302302
return Module()
303-
if self.cache.exists():
304-
objData = Module(file=str(self.cache))
305-
elif obj_fn.exists():
306-
objData = Module(file=obj_fn)
307303
else:
308304
print("getting objData from fresh query")
309305
if self.conf["type"] == "query":
310306
objData = self.api.runSavedQuery2(Type="query", ID=self.conf["id"])
311307
else:
312308
objData = self._get_obj_group(grpId=self.conf["id"])
313-
objData.toFile(path=obj_fn)
309+
# objData.toFile(path=obj_fn)
314310
return objData
315311

316312
def _qm_type(self, *, query: Search, Id: int):

src/mpapi/mink.py

+20
Original file line numberDiff line numberDiff line change
@@ -348,3 +348,23 @@ def _parse_conf(self, job: str, fn: Path) -> dict:
348348
except KeyError:
349349
raise SyntaxError("job '{job}' missing config value '{key}'")
350350
return job_data
351+
352+
353+
if __name__ == "__main__":
354+
# since fvh is blocked by Windows group policy
355+
import argparse
356+
from mpapi.constants import get_credentials
357+
358+
user, pw, baseURL = get_credentials()
359+
360+
parser = argparse.ArgumentParser(description="Commandline frontend for MpApi.py")
361+
parser.add_argument("-j", "--job", help="job to run") # , required=True
362+
parser.add_argument("-c", "--conf", help="config file", default="jobs.toml")
363+
parser.add_argument(
364+
"-v", "--version", help="Display version information", action="store_true"
365+
)
366+
args = parser.parse_args()
367+
if args.version:
368+
print(f"Version: {__version__}")
369+
sys.exit(0)
370+
Mink(job=args.job, conf=args.conf, baseURL=baseURL, pw=pw, user=user)

0 commit comments

Comments
 (0)