backupchan-cli 0.2.0__tar.gz → 0.2.2__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 (25) hide show
  1. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/CHANGELOG.md +8 -0
  2. {backupchan_cli-0.2.0/backupchan_cli.egg-info → backupchan_cli-0.2.2}/PKG-INFO +4 -5
  3. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/commands/backup.py +6 -20
  4. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/commands/config.py +1 -1
  5. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/main.py +1 -1
  6. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2/backupchan_cli.egg-info}/PKG-INFO +4 -5
  7. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli.egg-info/SOURCES.txt +0 -1
  8. backupchan_cli-0.2.2/backupchan_cli.egg-info/requires.txt +2 -0
  9. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/pyproject.toml +4 -5
  10. backupchan_cli-0.2.0/backupchan_cli/config.py +0 -72
  11. backupchan_cli-0.2.0/backupchan_cli.egg-info/requires.txt +0 -3
  12. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/.gitignore +0 -0
  13. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/LICENSE +0 -0
  14. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/README.md +0 -0
  15. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/__init__.py +0 -0
  16. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/commands/log.py +0 -0
  17. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/commands/recyclebin.py +0 -0
  18. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/commands/stats.py +0 -0
  19. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/commands/target.py +0 -0
  20. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli/utility.py +0 -0
  21. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli.egg-info/dependency_links.txt +0 -0
  22. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli.egg-info/entry_points.txt +0 -0
  23. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/backupchan_cli.egg-info/top_level.txt +0 -0
  24. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/cli.py +0 -0
  25. {backupchan_cli-0.2.0 → backupchan_cli-0.2.2}/setup.cfg +0 -0
@@ -2,6 +2,14 @@
2
2
 
3
3
  See what's changed between versions!
4
4
 
5
+ ## 0.2.2
6
+
7
+ * Refactored to use the API's new directory upload function.
8
+
9
+ ## 0.2.1
10
+
11
+ * Refactored to use the [client connection configuration library](https://github.com/Backupchan/client-config).
12
+
5
13
  ## 0.2.0
6
14
 
7
15
  * Added command to view stats.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: backupchan-cli
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Command-line interface for interacting with Backup-chan.
5
5
  Author-email: Moltony <koronavirusnyj@gmail.com>
6
6
  License: BSD-3-Clause
@@ -8,7 +8,7 @@ Project-URL: Homepage, https://github.com/Backupchan/cli
8
8
  Project-URL: Repository, https://github.com/Backupchan/cli.git
9
9
  Project-URL: Issues, https://github.com/Backupchan/cli/issues
10
10
  Project-URL: Changelog, https://github.com/Backupchan/cli/blob/main/CHANGELOG.md
11
- Classifier: Development Status :: 4 - Beta
11
+ Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Environment :: Console
13
13
  Classifier: License :: OSI Approved :: BSD License
14
14
  Classifier: Natural Language :: English
@@ -18,9 +18,8 @@ Classifier: Topic :: System :: Archiving :: Backup
18
18
  Classifier: Typing :: Typed
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
- Requires-Dist: backupchan-client-lib>=0.2.0
22
- Requires-Dist: keyring
23
- Requires-Dist: platformdirs
21
+ Requires-Dist: backupchan-client-lib>=0.3.0
22
+ Requires-Dist: backupchan-client-config>=0.1.0
24
23
  Dynamic: license-file
25
24
 
26
25
  # Backup-chan CLI
@@ -70,26 +70,12 @@ def setup_subcommands(subparser):
70
70
 
71
71
  def do_upload(args, _, api: API):
72
72
  if os.path.isdir(args.filename):
73
- # Cannot upload a directory to a single-file target.
74
- target_type = api.get_target(args.target_id)[0].target_type
75
- if target_type == BackupType.SINGLE:
76
- utility.failure("Cannot upload directory to a single file target")
77
-
78
- # Make a temporary gzipped tarball containing the directory contents.
79
- temp_dir = tempfile.gettempdir()
80
- temp_tar_path = os.path.join(temp_dir, f"bakch-{uuid.uuid4().hex}.tar.gz")
81
- with tarfile.open(temp_tar_path, "w:gz") as tar:
82
- tar.add(args.filename, arcname=os.path.basename(args.filename))
83
-
84
- # Upload our new tar.
85
- with open(temp_tar_path, "rb") as tar:
86
- try:
87
- api.upload_backup(args.target_id, tar, os.path.basename(args.filename) + ".tar.gz", not args.automatic)
88
- except requests.exceptions.ConnectionError:
89
- utility.failure_network()
90
- except BackupchanAPIError as exc:
91
- utility.failure(f"Failed to upload backup: {str(exc)}")
92
-
73
+ try:
74
+ api.upload_backup_folder(args.target_id, args.filename, not args.automatic)
75
+ except requests.exceptions.ConnectionError:
76
+ utility.failure_network()
77
+ except BackupchanAPIError as exc:
78
+ utility.failure(f"Failed to upload backup: {str(exc)}")
93
79
  else:
94
80
  with open(args.filename, "rb") as file:
95
81
  try:
@@ -1,5 +1,5 @@
1
1
  import os
2
- from backupchan_cli.config import Config
2
+ from backupchan_config import Config
3
3
  from backupchan_cli import utility
4
4
 
5
5
  #
@@ -1,6 +1,6 @@
1
1
  from .commands import config, target, backup, log, recyclebin, stats
2
- from .config import Config, ConfigException
3
2
  from .utility import failure, NO_CONFIG_MESSAGE
3
+ from backupchan_config import Config, ConfigException
4
4
  from backupchan import API
5
5
  import argparse
6
6
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: backupchan-cli
3
- Version: 0.2.0
3
+ Version: 0.2.2
4
4
  Summary: Command-line interface for interacting with Backup-chan.
5
5
  Author-email: Moltony <koronavirusnyj@gmail.com>
6
6
  License: BSD-3-Clause
@@ -8,7 +8,7 @@ Project-URL: Homepage, https://github.com/Backupchan/cli
8
8
  Project-URL: Repository, https://github.com/Backupchan/cli.git
9
9
  Project-URL: Issues, https://github.com/Backupchan/cli/issues
10
10
  Project-URL: Changelog, https://github.com/Backupchan/cli/blob/main/CHANGELOG.md
11
- Classifier: Development Status :: 4 - Beta
11
+ Classifier: Development Status :: 5 - Production/Stable
12
12
  Classifier: Environment :: Console
13
13
  Classifier: License :: OSI Approved :: BSD License
14
14
  Classifier: Natural Language :: English
@@ -18,9 +18,8 @@ Classifier: Topic :: System :: Archiving :: Backup
18
18
  Classifier: Typing :: Typed
19
19
  Description-Content-Type: text/markdown
20
20
  License-File: LICENSE
21
- Requires-Dist: backupchan-client-lib>=0.2.0
22
- Requires-Dist: keyring
23
- Requires-Dist: platformdirs
21
+ Requires-Dist: backupchan-client-lib>=0.3.0
22
+ Requires-Dist: backupchan-client-config>=0.1.0
24
23
  Dynamic: license-file
25
24
 
26
25
  # Backup-chan CLI
@@ -5,7 +5,6 @@ README.md
5
5
  cli.py
6
6
  pyproject.toml
7
7
  backupchan_cli/__init__.py
8
- backupchan_cli/config.py
9
8
  backupchan_cli/main.py
10
9
  backupchan_cli/utility.py
11
10
  backupchan_cli.egg-info/PKG-INFO
@@ -0,0 +1,2 @@
1
+ backupchan-client-lib>=0.3.0
2
+ backupchan-client-config>=0.1.0
@@ -1,21 +1,20 @@
1
1
  [project]
2
2
  name = "backupchan-cli"
3
- version = "0.2.0"
3
+ version = "0.2.2"
4
4
  description = "Command-line interface for interacting with Backup-chan."
5
5
  authors = [
6
6
  { name = "Moltony", email = "koronavirusnyj@gmail.com" }
7
7
  ]
8
8
  dependencies = [
9
- "backupchan-client-lib>=0.2.0",
10
- "keyring",
11
- "platformdirs"
9
+ "backupchan-client-lib>=0.3.0",
10
+ "backupchan-client-config>=0.1.0"
12
11
  ]
13
12
 
14
13
  readme = "README.md"
15
14
  license = {text = "BSD-3-Clause"}
16
15
 
17
16
  classifiers = [
18
- "Development Status :: 4 - Beta",
17
+ "Development Status :: 5 - Production/Stable",
19
18
  "Environment :: Console",
20
19
  "License :: OSI Approved :: BSD License",
21
20
  "Natural Language :: English",
@@ -1,72 +0,0 @@
1
- import json
2
- import sys
3
- import platformdirs
4
- import keyring
5
- import os
6
- from pathlib import Path
7
-
8
- class ConfigException(Exception):
9
- pass
10
-
11
- CONFIG_FILE_DIR = platformdirs.user_config_dir('backupchan')
12
- CONFIG_FILE_PATH = f"{CONFIG_FILE_DIR}/config.json"
13
-
14
- class Config:
15
- def __init__(self):
16
- self.port: int | None = None
17
- self.host: str | None = None
18
- self.api_key: str | None = None
19
-
20
- def read_config(self):
21
- if not os.path.exists(CONFIG_FILE_PATH):
22
- raise ConfigException("Config file not found")
23
-
24
- with open(CONFIG_FILE_PATH, "r") as config_file:
25
- self.parse_config(config_file.read())
26
- self.retrieve_api_key()
27
-
28
- def reset(self, write: bool = False):
29
- self.port = None
30
- self.host = None
31
- self.api_key = None
32
-
33
- if write:
34
- self.delete_api_key()
35
- if os.path.exists(CONFIG_FILE_PATH):
36
- os.remove(CONFIG_FILE_PATH)
37
-
38
- def is_incomplete(self):
39
- return self.port is None or self.host is None or self.api_key is None
40
-
41
- def parse_config(self, config: str):
42
- config_json = json.loads(config)
43
- self.port = config_json["port"]
44
- self.host = config_json["host"]
45
-
46
- def retrieve_api_key(self):
47
- self.api_key = keyring.get_password("backupchan", "api_key")
48
-
49
- def save_config(self):
50
- if self.is_incomplete():
51
- raise ConfigException("Cannot save incomplete config")
52
-
53
- Path(CONFIG_FILE_DIR).mkdir(exist_ok=True, parents=True)
54
-
55
- config_dict = {
56
- "host": self.host,
57
- "port": self.port
58
- }
59
-
60
- with open(CONFIG_FILE_PATH, "w") as config_file:
61
- json.dump(config_dict, config_file)
62
-
63
- self.save_api_key()
64
-
65
- def delete_api_key(self):
66
- try:
67
- keyring.delete_password("backupchan", "api_key")
68
- except keyring.errors.PasswordDeleteError:
69
- pass
70
-
71
- def save_api_key(self):
72
- keyring.set_password("backupchan", "api_key", self.api_key)
@@ -1,3 +0,0 @@
1
- backupchan-client-lib>=0.2.0
2
- keyring
3
- platformdirs
File without changes
File without changes
File without changes
File without changes