viur-cli 2.3.6__tar.gz → 2.3.7__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 (29) hide show
  1. {viur_cli-2.3.6/src/viur_cli.egg-info → viur_cli-2.3.7}/PKG-INFO +1 -1
  2. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/scriptor/cli.py +17 -84
  3. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/version.py +1 -1
  4. {viur_cli-2.3.6 → viur_cli-2.3.7/src/viur_cli.egg-info}/PKG-INFO +1 -1
  5. {viur_cli-2.3.6 → viur_cli-2.3.7}/LICENSE +0 -0
  6. {viur_cli-2.3.6 → viur_cli-2.3.7}/README.md +0 -0
  7. {viur_cli-2.3.6 → viur_cli-2.3.7}/pyproject.toml +0 -0
  8. {viur_cli-2.3.6 → viur_cli-2.3.7}/setup.cfg +0 -0
  9. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/__init__.py +0 -0
  10. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/build.py +0 -0
  11. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/cli.py +0 -0
  12. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/cloud.py +0 -0
  13. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/conf.py +0 -0
  14. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/deprecated.py +0 -0
  15. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/local.py +0 -0
  16. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/package.py +0 -0
  17. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/scriptor/__init__.py +0 -0
  18. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/scriptor/login.py +0 -0
  19. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/scripts/__init__.py +0 -0
  20. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/scripts/get_pyodide.py +0 -0
  21. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/setup.py +0 -0
  22. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/tool.py +0 -0
  23. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/update.py +0 -0
  24. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli/utils.py +0 -0
  25. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli.egg-info/SOURCES.txt +0 -0
  26. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli.egg-info/dependency_links.txt +0 -0
  27. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli.egg-info/entry_points.txt +0 -0
  28. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli.egg-info/requires.txt +0 -0
  29. {viur_cli-2.3.6 → viur_cli-2.3.7}/src/viur_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: viur-cli
3
- Version: 2.3.6
3
+ Version: 2.3.7
4
4
  Summary: Command-line interface for ViUR application maintenance.
5
5
  Author-email: "Andreas H. Kelch" <ak@mausbrand.de>
6
6
  License-Expression: MIT
@@ -4,7 +4,6 @@ import json
4
4
  import requests
5
5
  import os
6
6
  import hashlib
7
- import difflib
8
7
  import asyncio
9
8
  import sys
10
9
  import glob
@@ -24,7 +23,7 @@ def get_modules():
24
23
  global _modules
25
24
  if _modules is None:
26
25
  _modules = Modules(scriptor_config["base_url"], cookies=scriptor_config["cookies"])
27
- asyncio.run(_modules.init())
26
+ asyncio.new_event_loop().run_until_complete(_modules.init())
28
27
 
29
28
  return _modules
30
29
 
@@ -37,39 +36,22 @@ def script():
37
36
 
38
37
 
39
38
  @script.command()
40
- @click.option('--url', default=None, help='Set the server url')
39
+ @click.option('--url', default=None, help='Set the url')
41
40
  @click.option('--username', default=None, help='Set the username')
42
41
  @click.option('--working_dir', default=None, help='Set the working directory where scripts are stored to')
43
42
  def configure(url: str, username: str, working_dir: str):
44
43
  """
45
44
  Manage configuration settings.
46
45
  """
47
- if not any([url, username, working_dir]):
48
- click.echo("No parameters provided. Use one or more of the following options:")
49
- click.echo(" --url Set the server URL")
50
- click.echo(" --username Set the username")
51
- click.echo(" --working_dir Set the working directory where scripts are stored to")
52
- return
53
-
54
- changed = []
55
46
 
56
47
  if url:
57
48
  scriptor_config["base_url"] = url
58
- changed.append(f"url = {url}")
59
49
 
60
50
  if username:
61
51
  scriptor_config["username"] = username
62
- changed.append(f"username = {username}")
63
52
 
64
53
  if working_dir:
65
54
  scriptor_config["working_dir"] = working_dir.replace("\\", "/")
66
- changed.append(f"working_dir = {working_dir}")
67
-
68
- click.echo("Configuration updated:")
69
- for entry in changed:
70
- click.echo(f" {entry}")
71
-
72
- scriptor_config.save()
73
55
 
74
56
 
75
57
  @script.command()
@@ -129,8 +111,7 @@ def check_session(ctx: click.Context):
129
111
  get_modules()
130
112
 
131
113
  @script.command()
132
- @click.option('--force', default=False, is_flag=True,
133
- help='Overwrite local files without asking for confirmation')
114
+ @click.option('--force', default=False, help='Force replace files from server in local working directory')
134
115
  @click.pass_context
135
116
  def pull(ctx: click.Context, force: bool):
136
117
  """
@@ -144,74 +125,33 @@ def pull(ctx: click.Context, force: bool):
144
125
  tree = await modules.get_module("script")
145
126
  working_dir = scriptor_config.get("working_dir")
146
127
 
147
- stats = {"new": 0, "updated": 0, "skipped": 0, "unchanged": 0, "dirs": 0}
148
-
149
128
  async def process_entry(entry: dict, is_node: bool):
150
- _path = os.path.join(working_dir, entry["path"].lstrip("/"))
129
+ _path = os.path.join(working_dir, entry["path"])
151
130
 
152
131
  if is_node:
153
132
  if not os.path.exists(_path):
154
- click.echo(click.style(f" mkdir {entry['path']}", fg="blue"))
155
133
  os.makedirs(_path)
156
- stats["dirs"] += 1
157
134
  else:
158
- click.echo(f" check {entry['path']}", nl=False)
159
-
160
135
  def create_file():
161
136
  with open(_path, "a+") as f:
162
137
  f.write(entry["script"])
163
138
 
139
+ click.echo(f"Pull {_path}")
140
+
164
141
  if os.path.exists(_path):
165
142
  if force:
166
- with open(_path, "r") as f:
167
- changed = f.read().splitlines() != entry["script"].splitlines()
168
143
  os.remove(_path)
169
144
  create_file()
170
- if changed:
171
- click.echo(click.style(" [updated]", fg="yellow"))
172
- stats["updated"] += 1
173
- else:
174
- click.echo(click.style(" [ok]", fg="green"))
175
- stats["unchanged"] += 1
176
145
  else:
177
146
  with open(_path, "r") as f:
178
- local_content = f.read()
179
- remote_content = entry["script"]
180
- diff = list(difflib.unified_diff(
181
- remote_content.splitlines(),
182
- local_content.splitlines(),
183
- fromfile=f"server/{entry['path'].lstrip('/')}",
184
- tofile=f"local/{entry['path'].lstrip('/')}",
185
- lineterm="",
186
- ))
187
- if diff:
188
- click.echo(click.style(" [diff]", fg="yellow"))
189
- for line in diff:
190
- if line.startswith("+++") or line.startswith("---"):
191
- click.echo(click.style(line, bold=True))
192
- elif line.startswith("@@"):
193
- click.echo(click.style(line, fg="cyan"))
194
- elif line.startswith("+"):
195
- click.echo(click.style(line, fg="green"))
196
- elif line.startswith("-"):
197
- click.echo(click.style(line, fg="red"))
198
- else:
199
- click.echo(line)
200
- if click.confirm(f"Overwrite local {entry['path']} with remote version?"):
201
- os.remove(_path)
202
- create_file()
203
- stats["updated"] += 1
204
- else:
205
- stats["skipped"] += 1
206
- else:
207
- click.echo(click.style(" [ok]", fg="green"))
208
- stats["unchanged"] += 1
147
+ if hashlib.sha256(entry["script"].encode()).digest() \
148
+ != hashlib.sha256(f.read().encode()).digest():
149
+ if click.confirm(f"There is a difference with {entry['path']}. Overwrite?"):
150
+ os.remove(_path)
151
+ create_file()
152
+
209
153
  else:
210
- click.echo(click.style(" [new]", fg="green"))
211
154
  create_file()
212
- stats["new"] += 1
213
-
214
- click.echo("Fetching scripts from server...")
215
155
 
216
156
  # Process nodes first
217
157
  async for node in tree.list(skel_type="node"):
@@ -221,14 +161,7 @@ def pull(ctx: click.Context, force: bool):
221
161
  async for leaf in tree.list(skel_type="leaf"):
222
162
  await process_entry(leaf, False)
223
163
 
224
- click.echo("")
225
- click.echo(click.style("Summary:", bold=True))
226
- click.echo(f" new: {stats['new']}")
227
- click.echo(f" updated: {stats['updated']}")
228
- click.echo(f" skipped: {stats['skipped']}")
229
- click.echo(f" unchanged: {stats['unchanged']}")
230
-
231
- asyncio.run(main())
164
+ asyncio.new_event_loop().run_until_complete(main())
232
165
 
233
166
 
234
167
  @script.command()
@@ -380,7 +313,7 @@ def push(ctx: click.Context, force: bool, watch: bool):
380
313
  elif os.path.getmtime(event.src_path) == modified_files[event.src_path]:
381
314
  return
382
315
  modified_files[event.src_path] = os.path.getmtime(event.src_path)
383
- asyncio.run(main(event.src_path))
316
+ asyncio.new_event_loop().run_until_complete(main(event.src_path))
384
317
  except Exception as e:
385
318
  import traceback
386
319
  print(f"Error: on file {event.src_path} {e}")
@@ -408,9 +341,9 @@ def push(ctx: click.Context, force: bool, watch: bool):
408
341
  observer.stop()
409
342
  observer.join()
410
343
 
411
- watch_loop()
344
+ asyncio.new_event_loop().run_until_complete(watch_loop())
412
345
  return
413
- asyncio.run(main())
346
+ asyncio.new_event_loop().run_until_complete(main())
414
347
 
415
348
 
416
349
  @script.command()
@@ -443,4 +376,4 @@ def run(ctx: click.Context, path: str, args=None):
443
376
 
444
377
  await module.main()
445
378
 
446
- asyncio.run(main())
379
+ asyncio.new_event_loop().run_until_complete(main())
@@ -1,2 +1,2 @@
1
- __version__ = "2.3.6"
1
+ __version__ = "2.3.7"
2
2
  MINIMAL_PIPENV = "2023.11.15"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: viur-cli
3
- Version: 2.3.6
3
+ Version: 2.3.7
4
4
  Summary: Command-line interface for ViUR application maintenance.
5
5
  Author-email: "Andreas H. Kelch" <ak@mausbrand.de>
6
6
  License-Expression: MIT
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes