drove-cli 0.0.6__tar.gz → 0.0.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: drove-cli
3
- Version: 0.0.6
3
+ Version: 0.0.7
4
4
  Summary: Drove Command Line Interface
5
5
  License: Apache-2.0
6
6
  Keywords: container,docker,podman,distributed-systems,container-orchestrator
@@ -36,14 +36,14 @@ def run():
36
36
  except (BrokenPipeError, IOError, KeyboardInterrupt):
37
37
  pass
38
38
  except droveclient.DroveException as e:
39
- debug = True if client != None and client.debug else False
39
+ debug = True if client is not None and client.debug else False
40
40
  droveutils.print_drove_error(e, debug)
41
41
  if debug:
42
42
  traceback.print_exc()
43
43
 
44
44
  except Exception as e:
45
45
  print("Drove CLI error: " + str(e))
46
- debug = True if client != None and client.debug else False
46
+ debug = True if client is not None and client.debug else False
47
47
  if debug:
48
48
  traceback.print_exc()
49
49
  else:
@@ -8,14 +8,14 @@ from types import SimpleNamespace
8
8
  class DroveCli:
9
9
  def __init__(self, parser: argparse.ArgumentParser):
10
10
  self.parser = parser
11
- self.drove_client = droveclient.DroveClient()
12
11
  self.plugins: list = []
13
12
  self.debug = False
14
13
  subparsers = parser.add_subparsers(help="Available plugins")
14
+ drove_client = droveclient.DroveClient()
15
15
  for plugin_class in DrovePlugin.plugins:
16
16
  plugin = plugin_class()
17
17
  # print("Loading plugin: " + str(plugin))
18
- plugin.populate_options(drove_client=self.drove_client, subparser=subparsers)
18
+ plugin.populate_options(drove_client=drove_client, subparser=subparsers)
19
19
  self.plugins.append(plugin)
20
20
  parser.set_defaults(func=self.show_help)
21
21
 
@@ -23,10 +23,6 @@ class DroveCli:
23
23
  def run(self):
24
24
  args = self.parser.parse_args()
25
25
  self.debug = args.debug
26
- drove_client = droveclient.build_drove_client(self.drove_client, args=args)
27
- if drove_client is None:
28
- return None
29
- self.drove_client = drove_client
30
26
 
31
27
  # Load plugins
32
28
 
@@ -17,12 +17,20 @@ class DrovePlugin:
17
17
  def __init__(self) -> None:
18
18
  self.drove_client: droveclient.DroveClient = None
19
19
  self.parser: argparse.ArgumentParser = None
20
-
20
+
21
+ def needs_client(self) -> bool:
22
+ return True
23
+
21
24
  def populate_options(self, drove_client: droveclient.DroveClient, subparser: argparse.ArgumentParser):
22
25
  self.drove_client = drove_client
23
- subparser.set_defaults(func=self.process)
26
+ subparser.set_defaults(func=self.run_plugin)
24
27
  self.parser = subparser
25
28
 
29
+ def run_plugin(self, options: SimpleNamespace):
30
+ if self.needs_client():
31
+ droveclient.build_drove_client(self.drove_client, options)
32
+ self.process(options)
33
+
26
34
  def process(self, options: SimpleNamespace):
27
35
  self.parser.print_help()
28
36
  exit(-1)
@@ -85,6 +85,9 @@ class Config(plugins.DrovePlugin):
85
85
  def __init__(self) -> None:
86
86
  pass
87
87
 
88
+ def needs_client(self) -> bool:
89
+ return False
90
+
88
91
  def populate_options(self, drove_client, subparser: argparse.ArgumentParser):
89
92
  parser = subparser.add_parser("config", help="Manage drove cluster configurations")
90
93
  commands = parser.add_subparsers(help="Available config commands")
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "drove-cli"
3
- version = "0.0.6"
3
+ version = "0.0.7"
4
4
  description = "Drove Command Line Interface"
5
5
  authors = ["Santanu Sinha <santanu.sinha@gmail.com>"]
6
6
  maintainers = [
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes