queuemo 1.27.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. queuemo-1.27.6/LICENSE +21 -0
  2. queuemo-1.27.6/PKG-INFO +61 -0
  3. queuemo-1.27.6/README +10 -0
  4. queuemo-1.27.6/pyproject.toml +136 -0
  5. queuemo-1.27.6/queuemo/__init__.py +24 -0
  6. queuemo-1.27.6/queuemo/__main__.py +14 -0
  7. queuemo-1.27.6/queuemo/__patch__.py +8 -0
  8. queuemo-1.27.6/queuemo/cli/__init__.py +8 -0
  9. queuemo-1.27.6/queuemo/cli/main.py +185 -0
  10. queuemo-1.27.6/queuemo/cli/single.py +107 -0
  11. queuemo-1.27.6/queuemo/cli/state.py +104 -0
  12. queuemo-1.27.6/queuemo/cli/utils.py +26 -0
  13. queuemo-1.27.6/queuemo/recipes/__init__.py +59 -0
  14. queuemo-1.27.6/queuemo/recipes/fastview/__init__.py +26 -0
  15. queuemo-1.27.6/queuemo/recipes/fastview/after.py +21 -0
  16. queuemo-1.27.6/queuemo/recipes/fastview/before.py +76 -0
  17. queuemo-1.27.6/queuemo/recipes/fastview/titlepage.py +58 -0
  18. queuemo-1.27.6/queuemo/recipes/fastview/toc.py +42 -0
  19. queuemo-1.27.6/queuemo/recipes/logger.py +37 -0
  20. queuemo-1.27.6/queuemo/recipes/publish/__init__.py +8 -0
  21. queuemo-1.27.6/queuemo/recipes/publish/main.py +67 -0
  22. queuemo-1.27.6/queuemo/recipes/result/__init__.py +28 -0
  23. queuemo-1.27.6/queuemo/recipes/result/abbreviation.py +49 -0
  24. queuemo-1.27.6/queuemo/recipes/result/after.py +19 -0
  25. queuemo-1.27.6/queuemo/recipes/result/before.py +204 -0
  26. queuemo-1.27.6/queuemo/recipes/result/bibliography.py +88 -0
  27. queuemo-1.27.6/queuemo/recipes/result/chapter.py +41 -0
  28. queuemo-1.27.6/queuemo/recipes/result/colors.py +30 -0
  29. queuemo-1.27.6/queuemo/recipes/result/doctextstyle.py +99 -0
  30. queuemo-1.27.6/queuemo/recipes/result/footnote.py +42 -0
  31. queuemo-1.27.6/queuemo/recipes/result/imgfig.py +24 -0
  32. queuemo-1.27.6/queuemo/recipes/result/index.py +41 -0
  33. queuemo-1.27.6/queuemo/recipes/result/intro.py +75 -0
  34. queuemo-1.27.6/queuemo/recipes/result/links.py +39 -0
  35. queuemo-1.27.6/queuemo/recipes/result/magic.py +86 -0
  36. queuemo-1.27.6/queuemo/recipes/result/main.py +32 -0
  37. queuemo-1.27.6/queuemo/recipes/result/smarty.py +31 -0
  38. queuemo-1.27.6/queuemo/recipes/result/textflow.py +77 -0
  39. queuemo-1.27.6/queuemo/recipes/result/toc.py +44 -0
  40. queuemo-1.27.6/queuemo/recipes/result/view.py +117 -0
  41. queuemo-1.27.6/queuemo/recipes/utils.py +71 -0
  42. queuemo-1.27.6/queuemo/recipes/validation/__init__.py +8 -0
  43. queuemo-1.27.6/queuemo/recipes/validation/main.py +75 -0
  44. queuemo-1.27.6/queuemo/runnable.py +418 -0
  45. queuemo-1.27.6/queuemo/runtime/__init__.py +8 -0
  46. queuemo-1.27.6/queuemo/runtime/api.py +170 -0
  47. queuemo-1.27.6/queuemo/runtime/control.py +83 -0
  48. queuemo-1.27.6/queuemo/runtime/execute.py +60 -0
  49. queuemo-1.27.6/queuemo/runtime/runtime.py +206 -0
  50. queuemo-1.27.6/queuemo/runtime/scheduler.py +259 -0
  51. queuemo-1.27.6/queuemo/runtime/status.py +67 -0
  52. queuemo-1.27.6/queuemo/utils.py +95 -0
  53. queuemo-1.27.6/queuemo/worker/__init__.py +8 -0
  54. queuemo-1.27.6/queuemo/worker/startup.py +185 -0
  55. queuemo-1.27.6/queuemo.egg-info/PKG-INFO +61 -0
  56. queuemo-1.27.6/queuemo.egg-info/SOURCES.txt +63 -0
  57. queuemo-1.27.6/queuemo.egg-info/dependency_links.txt +1 -0
  58. queuemo-1.27.6/queuemo.egg-info/entry_points.txt +4 -0
  59. queuemo-1.27.6/queuemo.egg-info/requires.txt +37 -0
  60. queuemo-1.27.6/queuemo.egg-info/top_level.txt +1 -0
  61. queuemo-1.27.6/setup.cfg +4 -0
  62. queuemo-1.27.6/tests/test_cli.py +91 -0
  63. queuemo-1.27.6/tests/test_cli_single.py +97 -0
  64. queuemo-1.27.6/tests/test_recipe.py +30 -0
  65. queuemo-1.27.6/tests/test_scheduler.py +50 -0
queuemo-1.27.6/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Helmut Konrad Schewe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,61 @@
1
+ Metadata-Version: 2.4
2
+ Name: queuemo
3
+ Version: 1.27.6
4
+ Author-email: Helmut Konrad Schewe <helmutus@outlook.com>
5
+ License-Expression: MIT
6
+ Project-URL: Homepage, https://github.com/anaticulae/queuemo
7
+ Project-URL: Repository, https://github.com/anaticulae/queuemo
8
+ Classifier: Programming Language :: Python :: 3.12
9
+ Classifier: Programming Language :: Python :: 3.13
10
+ Classifier: Programming Language :: Python :: 3.14
11
+ Requires-Python: >=3.12
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: analp<2.0.0,>=1.1.0
15
+ Requires-Dist: bibliographia<2.0.0,>=1.0.1
16
+ Requires-Dist: callidus<2.0.0,>=1.7.1
17
+ Requires-Dist: capita<2.0.0,>=1.25.3
18
+ Requires-Dist: captions<2.0.0,>=1.0.1
19
+ Requires-Dist: codero<2.0.0,>=1.0.1
20
+ Requires-Dist: configos<2.0.0,>=1.0.4
21
+ Requires-Dist: decider-chapter<2.0.0,>=1.0.2
22
+ Requires-Dist: decider-con<2.0.0,>=1.0.1
23
+ Requires-Dist: decider-lay<2.0.0,>=1.0.0
24
+ Requires-Dist: decider-main<4.0.0,>=3.4.3
25
+ Requires-Dist: decider-ref<2.0.0,>=1.22.2
26
+ Requires-Dist: figureo<2.0.0,>=1.0.1
27
+ Requires-Dist: flask<4.0.0,>=3.1.3
28
+ Requires-Dist: groupmes<2.0.0,>=1.1.3
29
+ Requires-Dist: headnote<2.0.0,>=1.0.3
30
+ Requires-Dist: ibidem<2.0.0,>=1.0.2
31
+ Requires-Dist: indagator<2.0.0,>=1.0.2
32
+ Requires-Dist: indicibus<2.0.0,>=1.0.2
33
+ Requires-Dist: layouta<2.0.0,>=1.1.0
34
+ Requires-Dist: mundare<2.0.0,>=1.0.2
35
+ Requires-Dist: pagenumber<2.0.0,>=1.0.0
36
+ Requires-Dist: pdflog<2.0.0,>=1.0.2
37
+ Requires-Dist: qvlink<3.0.0,>=2.15.7
38
+ Requires-Dist: rawmaker<3.0.0,>=2.40.5
39
+ Requires-Dist: reftable<2.0.0,>=1.0.0
40
+ Requires-Dist: responsio<2.0.0,>=1.15.6
41
+ Requires-Dist: tablero<2.0.0,>=1.0.1
42
+ Requires-Dist: titulum<2.0.0,>=1.0.2
43
+ Requires-Dist: ughost<2.0.0,>=1.1.1
44
+ Requires-Dist: utilo<3.0.0,>=2.112.1
45
+ Requires-Dist: verbo<2.0.0,>=1.23.4
46
+ Provides-Extra: dev
47
+ Requires-Dist: gennex==1.1.0; extra == "dev"
48
+ Requires-Dist: hoverpower==1.7.0; extra == "dev"
49
+ Requires-Dist: utilotest==1.1.1; extra == "dev"
50
+ Dynamic: license-file
51
+
52
+ # queuemo
53
+
54
+ The back-end does the work. The back-end waits for new PDFs in a common file
55
+ space, after a new pdf arrives, the algorithms start there work. The plan how
56
+ to work is defined in `recipes`.
57
+
58
+ Features:
59
+
60
+ * recipes
61
+ * publishing
queuemo-1.27.6/README ADDED
@@ -0,0 +1,10 @@
1
+ # queuemo
2
+
3
+ The back-end does the work. The back-end waits for new PDFs in a common file
4
+ space, after a new pdf arrives, the algorithms start there work. The plan how
5
+ to work is defined in `recipes`.
6
+
7
+ Features:
8
+
9
+ * recipes
10
+ * publishing
@@ -0,0 +1,136 @@
1
+ [build-system]
2
+ requires = [
3
+ "setuptools>=83.0.0",
4
+ "wheel>=0.47.0",
5
+ ]
6
+ build-backend = "setuptools.build_meta"
7
+
8
+ [project]
9
+ name = "queuemo"
10
+ version = "1.27.6"
11
+ description = ""
12
+ requires-python = ">=3.12"
13
+ authors = [
14
+ { name = "Helmut Konrad Schewe", email = "helmutus@outlook.com" },
15
+ ]
16
+ dependencies = [
17
+ "analp>=1.1.0,<2.0.0",
18
+ "bibliographia>=1.0.1,<2.0.0",
19
+ "callidus>=1.7.1,<2.0.0",
20
+ "capita>=1.25.3,<2.0.0",
21
+ "captions>=1.0.1,<2.0.0",
22
+ "codero>=1.0.1,<2.0.0",
23
+ "configos>=1.0.4,<2.0.0",
24
+ "decider-chapter>=1.0.2,<2.0.0",
25
+ "decider-con>=1.0.1,<2.0.0",
26
+ "decider-lay>=1.0.0,<2.0.0",
27
+ "decider-main>=3.4.3,<4.0.0",
28
+ "decider-ref>=1.22.2,<2.0.0",
29
+ "figureo>=1.0.1,<2.0.0",
30
+ "flask>=3.1.3,<4.0.0",
31
+ "groupmes>=1.1.3,<2.0.0",
32
+ "headnote>=1.0.3,<2.0.0",
33
+ "ibidem>=1.0.2,<2.0.0",
34
+ "indagator>=1.0.2,<2.0.0",
35
+ "indicibus>=1.0.2,<2.0.0",
36
+ "layouta>=1.1.0,<2.0.0",
37
+ "mundare>=1.0.2,<2.0.0",
38
+ "pagenumber>=1.0.0,<2.0.0",
39
+ "pdflog>=1.0.2,<2.0.0",
40
+ "qvlink>=2.15.7,<3.0.0",
41
+ "rawmaker>=2.40.5,<3.0.0",
42
+ "reftable>=1.0.0,<2.0.0",
43
+ "responsio>=1.15.6,<2.0.0",
44
+ "tablero>=1.0.1,<2.0.0",
45
+ "titulum>=1.0.2,<2.0.0",
46
+ "ughost>=1.1.1,<2.0.0",
47
+ "utilo>=2.112.1,<3.0.0",
48
+ "verbo>=1.23.4,<2.0.0",
49
+ ]
50
+ keywords = []
51
+ classifiers = [
52
+ "Programming Language :: Python :: 3.12",
53
+ "Programming Language :: Python :: 3.13",
54
+ "Programming Language :: Python :: 3.14",
55
+ ]
56
+ license = "MIT"
57
+ license-files = [
58
+ "LICENSE",
59
+ ]
60
+
61
+ [project.readme]
62
+ file = "README"
63
+ content-type = "text/markdown"
64
+
65
+ [project.optional-dependencies]
66
+ dev = [
67
+ "gennex==1.1.0",
68
+ "hoverpower==1.7.0",
69
+ "utilotest==1.1.1",
70
+ ]
71
+
72
+ [project.urls]
73
+ Homepage = "https://github.com/anaticulae/queuemo"
74
+ Repository = "https://github.com/anaticulae/queuemo"
75
+
76
+ [project.scripts]
77
+ queuemo = "queuemo.cli.main:main"
78
+ queuemo_single = "queuemo.cli.single:main"
79
+ queuemo_state = "queuemo.cli.state:main"
80
+
81
+ [tool.semantic_release]
82
+ version_toml = [
83
+ "pyproject.toml:project.version",
84
+ ]
85
+
86
+ [tool.semantic_release.changelog]
87
+ mode = "init"
88
+ output_format = "md"
89
+
90
+ [tool.semantic_release.changelog.default_templates]
91
+ changelog_file = "CHANGELOG"
92
+
93
+ [tool.semantic_release.commit_parser_options]
94
+ patch_tags = [
95
+ "build",
96
+ "chore",
97
+ "ci",
98
+ "deps",
99
+ "docs",
100
+ "fix",
101
+ "perf",
102
+ "refactor",
103
+ "style",
104
+ "test",
105
+ ]
106
+ minor_tags = [
107
+ "feat",
108
+ ]
109
+
110
+ [tool.setuptools.packages.find]
111
+ where = [
112
+ ".",
113
+ ]
114
+ include = [
115
+ "queuemo",
116
+ "queuemo.cli",
117
+ "queuemo.recipes",
118
+ "queuemo.recipes.fastview",
119
+ "queuemo.recipes.publish",
120
+ "queuemo.recipes.result",
121
+ "queuemo.recipes.validation",
122
+ "queuemo.runtime",
123
+ "queuemo.worker",
124
+ ]
125
+ exclude = [
126
+ "tests*",
127
+ ]
128
+
129
+ [tool.hoverpower]
130
+ packages = [
131
+ "BACHELOR",
132
+ "HOME",
133
+ "MASTER",
134
+ "ORDER",
135
+ "PAPER",
136
+ ]
@@ -0,0 +1,24 @@
1
+ #==============================================================================
2
+ # C O P Y R I G H T
3
+ #------------------------------------------------------------------------------
4
+ # Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ #==============================================================================
9
+
10
+ import importlib.metadata
11
+ import os
12
+
13
+ import queuemo.__patch__
14
+ from queuemo.runtime.api import RecipeIO
15
+ from queuemo.runtime.scheduler import isrequired
16
+ from queuemo.runtime.scheduler import required
17
+
18
+ __version__ = importlib.metadata.version('queuemo')
19
+
20
+ ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
21
+
22
+ PROCESS = 'queuemo'
23
+
24
+ INTERACTIVE = False # if True, pause on every scheduler step
@@ -0,0 +1,14 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+ """Evaluate cmd-args and execute commands"""
10
+
11
+ import queuemo.cli.main
12
+
13
+ if __name__ == "__main__":
14
+ queuemo.cli.main.main()
@@ -0,0 +1,8 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
@@ -0,0 +1,8 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2022-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
@@ -0,0 +1,185 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2019-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+
10
+ import collections
11
+
12
+ import configos
13
+ import qvlink
14
+ import serializeraw
15
+ import utilo
16
+ import utilo.cli
17
+
18
+ import queuemo
19
+ import queuemo.cli.utils
20
+ import queuemo.runnable
21
+
22
+ RUNTIME = 'runtime'
23
+ WAITING = 'waiting'
24
+ JOBS = 'jobs'
25
+ VERBOSE = 'verbose'
26
+ INTERACTIVE = 'interactive'
27
+
28
+ Config = collections.namedtuple(
29
+ 'Config',
30
+ ('interactive failfast showdebug clean runtime waiting '
31
+ 'jobs verbose http skip_unsupported webconfig'),
32
+ )
33
+
34
+
35
+ @utilo.saveme
36
+ def main():
37
+ config = evaluate_cli()
38
+ if config == utilo.INVALID_COMMAND:
39
+ return utilo.INVALID_COMMAND
40
+ # run showdebug
41
+ if config.showdebug:
42
+ return showdebug()
43
+ configure(config)
44
+ closed = worker_startup(config)
45
+ return closed
46
+
47
+
48
+ def configure(config: Config):
49
+ queuemo.INTERACTIVE = config.interactive
50
+ queuemo.cli.utils.logger_start()
51
+ if config.interactive:
52
+ utilo.log('use interactive mode')
53
+ if not utilo.testing():
54
+ # ensure that all test directories are created
55
+ configos.makedirs()
56
+ # check startup
57
+ configos.check_startup()
58
+ if config.clean:
59
+ # remove outdated maybe failed jobs
60
+ qvlink.remove_outdated()
61
+ # run http interface if required
62
+ if config.http:
63
+ http_startup()
64
+
65
+
66
+ def worker_startup(config: Config):
67
+ # start scheduler
68
+ import queuemo.worker.startup # pylint:disable=W0621,C0415
69
+ closed = queuemo.worker.startup.run(
70
+ failfast=config.failfast,
71
+ jobs=config.jobs,
72
+ runtime=config.runtime,
73
+ skip_unsupported=config.skip_unsupported,
74
+ verbose=config.verbose,
75
+ waiting=config.waiting,
76
+ webconfig=config.webconfig,
77
+ )
78
+ return closed
79
+
80
+
81
+ def http_startup():
82
+ # lower queuemo start time, flask requires a second of init time
83
+ import queuemo.runtime.control # pylint:disable=W0621,C0415
84
+ queuemo.runtime.control.start()
85
+
86
+
87
+ CMDS = [
88
+ utilo.Parameter(
89
+ longcut=RUNTIME,
90
+ message='runtime in ticks',
91
+ args={
92
+ 'default': 100,
93
+ },
94
+ ),
95
+ utilo.Parameter(
96
+ longcut=WAITING,
97
+ message='time to wait for the next job in miliseconds',
98
+ args={
99
+ 'default': 1000,
100
+ },
101
+ ),
102
+ utilo.Parameter(
103
+ longcut=JOBS,
104
+ message='maximal number of executed jobs',
105
+ args={
106
+ 'default': 1000,
107
+ },
108
+ ),
109
+ utilo.Flag(
110
+ longcut=INTERACTIVE,
111
+ message='pause on every recipe step and ask to continue',
112
+ ),
113
+ utilo.Flag(
114
+ longcut='failfast',
115
+ message='fail on first error',
116
+ ),
117
+ utilo.Flag(
118
+ longcut='http',
119
+ message='start http interface',
120
+ ),
121
+ utilo.Flag(
122
+ longcut='showdebug',
123
+ message='show list of installed runnable and return',
124
+ ),
125
+ utilo.Flag(
126
+ longcut='clean',
127
+ message='clean outdated jobs',
128
+ ),
129
+ utilo.Flag(
130
+ longcut='skip_unsupported',
131
+ message='do not analyze not supported documents',
132
+ ),
133
+ utilo.Parameter(
134
+ longcut='webconfig',
135
+ message='select msgids of published findings',
136
+ ),
137
+ ]
138
+
139
+
140
+ def evaluate_cli() -> Config:
141
+ parser = utilo.cli.create_parser(
142
+ todo=CMDS,
143
+ config=utilo.ParserConfiguration(
144
+ waitingflag=False,
145
+ cacheflag=False,
146
+ pages=False,
147
+ ),
148
+ prog=queuemo.PROCESS,
149
+ version=queuemo.__version__,
150
+ )
151
+ args = utilo.parse(parser)
152
+ try:
153
+ webconfig = args.get('webconfig', None)
154
+ if webconfig:
155
+ if not utilo.exists(webconfig):
156
+ utilo.error(f'webconfig does not exists: {webconfig}')
157
+ return utilo.INVALID_COMMAND
158
+ utilo.debug(f'use webconfig: {webconfig}')
159
+ webconfig = serializeraw.load_webconfig(webconfig)
160
+ config = Config(
161
+ args[INTERACTIVE],
162
+ args.get('failfast', False),
163
+ args.get('showdebug', False),
164
+ args.get('clean', False),
165
+ int(args[RUNTIME]),
166
+ int(args[WAITING]),
167
+ int(args[JOBS]),
168
+ int(args[VERBOSE]) if args[VERBOSE] else 0,
169
+ args.get('http', False),
170
+ args.get('skip_unsupported', False),
171
+ webconfig=webconfig,
172
+ )
173
+ except ValueError:
174
+ msg = (f'invalid start parameter: `{args[RUNTIME]}`, `{args[WAITING]}`,'
175
+ f' `{args[VERBOSE]}`, `{args[JOBS]}`')
176
+ utilo.error(args)
177
+ utilo.error(msg)
178
+ return utilo.INVALID_COMMAND
179
+ utilo.level_setup(config.verbose)
180
+ return config
181
+
182
+
183
+ def showdebug():
184
+ queuemo.runnable.check()
185
+ return utilo.SUCCESS
@@ -0,0 +1,107 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2020-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+ """Run queuemo for selected pdf file."""
10
+
11
+ import os
12
+
13
+ import configos
14
+ import qvlink
15
+ import utilo
16
+ import utilo.cli
17
+ import utilo.logger
18
+
19
+ import queuemo
20
+ import queuemo.cli.utils
21
+ import queuemo.runtime.api
22
+ import queuemo.runtime.execute
23
+ import queuemo.worker.startup
24
+
25
+ COMMANDS = [
26
+ utilo.Flag(longcut='create'),
27
+ ]
28
+ DESCRIPTION = """\
29
+ Run queuemo recipe for given -i input and write to -o folder.
30
+ """
31
+
32
+
33
+ @utilo.saveme
34
+ def main() -> int:
35
+ inpath, outpath, verbose, create = eval_cli()
36
+ utilo.logger.level_setup(utilo.Level(verbose))
37
+ queuemo.cli.utils.logger_start()
38
+ if os.path.isfile(inpath):
39
+ if create:
40
+ inpath = create_todo(inpath, outpath)
41
+ if inpath == utilo.FAILURE:
42
+ return utilo.FAILURE
43
+ else:
44
+ utilo.error(f'require directory: {inpath} or use --create flag')
45
+ return utilo.INVALID_COMMAND
46
+ outpath = inpath
47
+ utilo.log(f'write result to: {outpath}')
48
+ # patch todo outpath path. TODO: INVESTIGATE HERE?
49
+ todopath = os.path.normpath(os.path.join(inpath, os.path.pardir))
50
+ configos.todo = lambda _=False: todopath
51
+ configos.ready = lambda _=False: todopath
52
+ # analyze single document
53
+ tmpdir = utilo.tmpdir(configos.tmp())
54
+ jobid = queuemo.worker.startup.jobid(inpath)
55
+ queuemo.runtime.execute.run_document(
56
+ workspace=tmpdir,
57
+ documentid=jobid,
58
+ outpath=outpath,
59
+ config=queuemo.runtime.api.RecipeConfig(verbose=verbose),
60
+ )
61
+ return utilo.SUCCESS
62
+
63
+
64
+ def eval_cli() -> tuple:
65
+ parser = utilo.cli.create_parser(
66
+ description=DESCRIPTION,
67
+ todo=COMMANDS,
68
+ config=utilo.ParserConfiguration(
69
+ inputparameter=True,
70
+ outputparameter=True,
71
+ ),
72
+ prog='queuemo_single',
73
+ version=queuemo.__version__,
74
+ )
75
+ args = utilo.parse(parser)
76
+ inpath, outpath, verbose = utilo.sources( # pylint:disable=W0632
77
+ args,
78
+ singleinput=True,
79
+ use_cwd=False,
80
+ verbose=True,
81
+ )
82
+ inpath = inpath[0]
83
+ create = args.get('create', False)
84
+ return inpath, outpath, verbose, create
85
+
86
+
87
+ def create_todo(inpath, outpath):
88
+ filename = str(os.path.split(inpath)[1])
89
+ if outpath:
90
+ outpath, outname = os.path.split(outpath)
91
+ else:
92
+ outpath = os.getcwd()
93
+ # remove file name
94
+ outname = filename.replace('.pdf', '')
95
+ try:
96
+ outpath = qvlink.create_todo(
97
+ file=inpath,
98
+ filename=filename,
99
+ todoname=outname,
100
+ todopath=outpath,
101
+ exist_ok=True,
102
+ )
103
+ except OSError:
104
+ utilo.error(f'{os.path.join(outpath, outname)} already exists')
105
+ return utilo.FAILURE
106
+ utilo.log(f'create job description in {outpath}')
107
+ return outpath
@@ -0,0 +1,104 @@
1
+ # =============================================================================
2
+ # C O P Y R I G H T
3
+ # -----------------------------------------------------------------------------
4
+ # Copyright (c) 2022-2023 by Helmut Konrad Schewe. All rights reserved.
5
+ # This file is property of Helmut Konrad Schewe. Any unauthorized copy,
6
+ # use or distribution is an offensive act against international law and may
7
+ # be prosecuted under federal law. Its content is company confidential.
8
+ # =============================================================================
9
+
10
+ import argparse
11
+ import sys
12
+
13
+ import configos
14
+ import qvlink
15
+ import utilo
16
+
17
+
18
+ @utilo.saveme
19
+ def main() -> int:
20
+ action = eval_cli()
21
+ if action.kill:
22
+ kill(action.kill)
23
+ return utilo.SUCCESS
24
+ utilo.log('verify state ...')
25
+ utilo.log(f' todo: {configos.todo()}')
26
+ print_running()
27
+ print_waiting()
28
+ return utilo.SUCCESS
29
+
30
+
31
+ def print_running():
32
+ print_documents(qvlink.State.RUNNING)
33
+
34
+
35
+ def print_waiting():
36
+ print_documents(qvlink.State.WAITING)
37
+
38
+
39
+ def print_documents(state):
40
+ # TODO: PASS READY AND TODO TO AVOID REQUIRED COMMON PARENT
41
+ common = utilo.path_parent(configos.ready())
42
+ documents = qvlink.load_documents(
43
+ common=common,
44
+ owner=None,
45
+ state=state,
46
+ )
47
+ if not documents:
48
+ utilo.log(f'no {state.name} documents')
49
+ return
50
+ utilo.log(f'\n{state.name} documents({len(documents)}):')
51
+ for document in documents:
52
+ print_document(document)
53
+
54
+
55
+ def print_document(document):
56
+ pages = str(document.get('pages')).zfill(3)
57
+ title = document.get('title')
58
+ date = document.get('date')
59
+ name = document.get('name')
60
+ utilo.log(f' - {name} {date} {pages} {title}')
61
+
62
+
63
+ def kill(documentid: str):
64
+ if documentid == 'all':
65
+ todos = collect_all()
66
+ if not todos:
67
+ utilo.error('nothing to kill')
68
+ sys.exit(utilo.INVALID_COMMAND)
69
+ for jobinfo in todos:
70
+ kill(jobinfo.name)
71
+ return
72
+ if not qvlink.document(documentid=documentid):
73
+ utilo.exitx(f'invalid documentid: {documentid}', utilo.INVALID_COMMAND)
74
+ if qvlink.deleted(documentid):
75
+ utilo.exitx(f'already deleted: {documentid}', utilo.INVALID_COMMAND)
76
+ return
77
+ if qvlink.delete(documentid):
78
+ utilo.log(f'killed: {documentid}')
79
+ return
80
+ utilo.error(f'could not kill: {documentid}')
81
+ sys.exit(utilo.INVALID_COMMAND)
82
+
83
+
84
+ def collect_all() -> list:
85
+ todos = qvlink.collect_jobs()[0]
86
+ result = []
87
+ for todo in todos:
88
+ process = qvlink.current(todo.documentid)
89
+ current: qvlink.State = qvlink.State.fromstate(process)
90
+ if current not in (qvlink.State.WAITING, qvlink.State.RUNNING):
91
+ continue
92
+ result.append(todo)
93
+ return result
94
+
95
+
96
+ def eval_cli():
97
+ parser = argparse.ArgumentParser(prog='queuemo_state',)
98
+ parser.add_argument(
99
+ '--kill',
100
+ nargs='?',
101
+ help='stop single job, use all to stop all pending jobs',
102
+ )
103
+ result = parser.parse_args()
104
+ return result