skilleter-thingy 0.0.38__tar.gz → 0.0.40__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.

Potentially problematic release.


This version of skilleter-thingy might be problematic. Click here for more details.

Files changed (75) hide show
  1. {skilleter_thingy-0.0.38/src/skilleter_thingy.egg-info → skilleter_thingy-0.0.40}/PKG-INFO +1 -1
  2. skilleter_thingy-0.0.40/pyproject.toml +84 -0
  3. {skilleter_thingy-0.0.38 → skilleter_thingy-0.0.40/src/skilleter_thingy.egg-info}/PKG-INFO +1 -1
  4. skilleter_thingy-0.0.40/src/skilleter_thingy.egg-info/SOURCES.txt +9 -0
  5. skilleter_thingy-0.0.40/src/skilleter_thingy.egg-info/entry_points.txt +43 -0
  6. skilleter_thingy-0.0.40/src/skilleter_thingy.egg-info/top_level.txt +1 -0
  7. skilleter_thingy-0.0.38/pyproject.toml +0 -84
  8. skilleter_thingy-0.0.38/src/__init__.py +0 -6
  9. skilleter_thingy-0.0.38/src/addpath.py +0 -107
  10. skilleter_thingy-0.0.38/src/borger.py +0 -269
  11. skilleter_thingy-0.0.38/src/console_colours.py +0 -63
  12. skilleter_thingy-0.0.38/src/diskspacecheck.py +0 -67
  13. skilleter_thingy-0.0.38/src/docker_purge.py +0 -113
  14. skilleter_thingy-0.0.38/src/ffind.py +0 -536
  15. skilleter_thingy-0.0.38/src/ggit.py +0 -90
  16. skilleter_thingy-0.0.38/src/ggrep.py +0 -154
  17. skilleter_thingy-0.0.38/src/git_br.py +0 -180
  18. skilleter_thingy-0.0.38/src/git_ca.py +0 -142
  19. skilleter_thingy-0.0.38/src/git_cleanup.py +0 -287
  20. skilleter_thingy-0.0.38/src/git_co.py +0 -220
  21. skilleter_thingy-0.0.38/src/git_common.py +0 -61
  22. skilleter_thingy-0.0.38/src/git_hold.py +0 -154
  23. skilleter_thingy-0.0.38/src/git_mr.py +0 -92
  24. skilleter_thingy-0.0.38/src/git_parent.py +0 -77
  25. skilleter_thingy-0.0.38/src/git_review.py +0 -1428
  26. skilleter_thingy-0.0.38/src/git_update.py +0 -385
  27. skilleter_thingy-0.0.38/src/git_wt.py +0 -96
  28. skilleter_thingy-0.0.38/src/gitcmp_helper.py +0 -322
  29. skilleter_thingy-0.0.38/src/gitprompt.py +0 -274
  30. skilleter_thingy-0.0.38/src/gl.py +0 -174
  31. skilleter_thingy-0.0.38/src/gphotosync.py +0 -610
  32. skilleter_thingy-0.0.38/src/linecount.py +0 -155
  33. skilleter_thingy-0.0.38/src/moviemover.py +0 -133
  34. skilleter_thingy-0.0.38/src/photodupe.py +0 -136
  35. skilleter_thingy-0.0.38/src/phototidier.py +0 -248
  36. skilleter_thingy-0.0.38/src/py_audit.py +0 -131
  37. skilleter_thingy-0.0.38/src/readable.py +0 -270
  38. skilleter_thingy-0.0.38/src/remdir.py +0 -126
  39. skilleter_thingy-0.0.38/src/rmdupe.py +0 -550
  40. skilleter_thingy-0.0.38/src/rpylint.py +0 -91
  41. skilleter_thingy-0.0.38/src/skilleter_thingy.egg-info/SOURCES.txt +0 -69
  42. skilleter_thingy-0.0.38/src/skilleter_thingy.egg-info/entry_points.txt +0 -43
  43. skilleter_thingy-0.0.38/src/skilleter_thingy.egg-info/top_level.txt +0 -43
  44. skilleter_thingy-0.0.38/src/splitpics.py +0 -99
  45. skilleter_thingy-0.0.38/src/strreplace.py +0 -82
  46. skilleter_thingy-0.0.38/src/sysmon.py +0 -435
  47. skilleter_thingy-0.0.38/src/tfm.py +0 -920
  48. skilleter_thingy-0.0.38/src/tfparse.py +0 -101
  49. skilleter_thingy-0.0.38/src/thingy/__init__.py +0 -0
  50. skilleter_thingy-0.0.38/src/thingy/colour.py +0 -213
  51. skilleter_thingy-0.0.38/src/thingy/dc_curses.py +0 -278
  52. skilleter_thingy-0.0.38/src/thingy/dc_defaults.py +0 -221
  53. skilleter_thingy-0.0.38/src/thingy/dc_util.py +0 -50
  54. skilleter_thingy-0.0.38/src/thingy/dircolors.py +0 -308
  55. skilleter_thingy-0.0.38/src/thingy/docker.py +0 -95
  56. skilleter_thingy-0.0.38/src/thingy/files.py +0 -142
  57. skilleter_thingy-0.0.38/src/thingy/git.py +0 -1371
  58. skilleter_thingy-0.0.38/src/thingy/git2.py +0 -1307
  59. skilleter_thingy-0.0.38/src/thingy/gitlab.py +0 -193
  60. skilleter_thingy-0.0.38/src/thingy/logger.py +0 -112
  61. skilleter_thingy-0.0.38/src/thingy/path.py +0 -156
  62. skilleter_thingy-0.0.38/src/thingy/popup.py +0 -87
  63. skilleter_thingy-0.0.38/src/thingy/process.py +0 -112
  64. skilleter_thingy-0.0.38/src/thingy/run.py +0 -334
  65. skilleter_thingy-0.0.38/src/thingy/tfm_pane.py +0 -595
  66. skilleter_thingy-0.0.38/src/thingy/tidy.py +0 -160
  67. skilleter_thingy-0.0.38/src/trimpath.py +0 -84
  68. skilleter_thingy-0.0.38/src/window_rename.py +0 -92
  69. skilleter_thingy-0.0.38/src/xchmod.py +0 -125
  70. skilleter_thingy-0.0.38/src/yamlcheck.py +0 -89
  71. {skilleter_thingy-0.0.38 → skilleter_thingy-0.0.40}/LICENSE +0 -0
  72. {skilleter_thingy-0.0.38 → skilleter_thingy-0.0.40}/README.md +0 -0
  73. {skilleter_thingy-0.0.38 → skilleter_thingy-0.0.40}/setup.cfg +0 -0
  74. {skilleter_thingy-0.0.38 → skilleter_thingy-0.0.40}/src/skilleter_thingy.egg-info/dependency_links.txt +0 -0
  75. {skilleter_thingy-0.0.38 → skilleter_thingy-0.0.40}/src/skilleter_thingy.egg-info/requires.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: skilleter_thingy
3
- Version: 0.0.38
3
+ Version: 0.0.40
4
4
  Summary: A collection of useful utilities, mainly aimed at making Git more friendly
5
5
  Author-email: John Skilleter <john@skilleter.org.uk>
6
6
  Project-URL: Home, https://skilleter.org.uk
@@ -0,0 +1,84 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "skilleter_thingy"
7
+
8
+ # Version must be incremented to install updated Thingy
9
+
10
+ version = "0.0.40"
11
+
12
+ authors = [
13
+ {name="John Skilleter", email="john@skilleter.org.uk"},
14
+ ]
15
+
16
+ description = "A collection of useful utilities, mainly aimed at making Git more friendly"
17
+
18
+ readme = "README.md"
19
+
20
+ requires-python = ">=3.6"
21
+
22
+ classifiers = [
23
+ "Programming Language :: Python :: 3",
24
+ "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
25
+ "Operating System :: OS Independent",
26
+ ]
27
+
28
+ dependencies = [
29
+ "imagehash",
30
+ "inotify",
31
+ "pillow",
32
+ "psutil",
33
+ "pyaml",
34
+ "pygit2",
35
+ "python-dateutil",
36
+ "requests",
37
+ ]
38
+
39
+ [project.urls]
40
+ Home = "https://skilleter.org.uk"
41
+
42
+ [project.scripts]
43
+ addpath = "skilleter_thingy:addpath.addpath"
44
+ borger = "skilleter_thingy:borger.borger"
45
+ console_colours = "skilleter_thingy:console_colours.console_colours"
46
+ diskspacecheck = "skilleter_thingy:diskspacecheck.diskspacecheck"
47
+ docker-purge = "skilleter_thingy:docker_purge.docker_purge"
48
+ ffind = "skilleter_thingy:ffind.ffind"
49
+ ggit = "skilleter_thingy:ggit.ggit"
50
+ ggrep = "skilleter_thingy:ggrep.ggrep"
51
+ git-br = "skilleter_thingy:git_br.git_br"
52
+ git-ca = "skilleter_thingy:git_ca.git_ca"
53
+ git-cleanup = "skilleter_thingy:git_cleanup.git_cleanup"
54
+ git-co = "skilleter_thingy:git_co.git_co"
55
+ git-common = "skilleter_thingy:git_common.git_common"
56
+ git-hold = "skilleter_thingy:git_hold.git_hold"
57
+ git-mr = "skilleter_thingy:git_mr.git_mr"
58
+ git-parent = "skilleter_thingy:git_parent.git_parent"
59
+ git-review = "skilleter_thingy:git_review.git_review"
60
+ git-update = "skilleter_thingy:git_update.git_update"
61
+ git-wt = "skilleter_thingy:git_wt.git_wt"
62
+ gitcmp-helper = "skilleter_thingy:gitcmp_helper.gitcmp_helper"
63
+ gitprompt = "skilleter_thingy:gitprompt.gitprompt"
64
+ gl = "skilleter_thingy:gl.gl"
65
+ gphotosync = "skilleter_thingy:gphotosync.gphotosync"
66
+ linecount = "skilleter_thingy:linecount.linecount"
67
+ moviemover = "skilleter_thingy:moviemover.moviemover"
68
+ photodupe = "skilleter_thingy:photodupe.photodupe"
69
+ phototidier = "skilleter_thingy:phototidier.phototidier"
70
+ py-audit = "skilleter_thingy:py_audit.py_audit"
71
+ readable = "skilleter_thingy:readable.readable"
72
+ remdir = "skilleter_thingy:remdir.remdir"
73
+ rmdupe = "skilleter_thingy:rmdupe.rmdupe"
74
+ rpylint = "skilleter_thingy:rpylint.rpylint"
75
+ s3-sync = "skilleter_thingy:s3_sync.s3_sync"
76
+ splitpics = "skilleter_thingy:splitpics.splitpics"
77
+ strreplace = "skilleter_thingy:strreplace.strreplace"
78
+ sysmon = "skilleter_thingy:sysmon.sysmon"
79
+ tfm = "skilleter_thingy:tfm.tfm"
80
+ tfparse = "skilleter_thingy:tfparse.tfparse"
81
+ trimpath = "skilleter_thingy:trimpath.trimpath"
82
+ window-rename = "skilleter_thingy:window_rename.window_rename"
83
+ xchmod = "skilleter_thingy:xchmod.xchmod"
84
+ yamlcheck = "skilleter_thingy:yamlcheck.yamlcheck"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: skilleter_thingy
3
- Version: 0.0.38
3
+ Version: 0.0.40
4
4
  Summary: A collection of useful utilities, mainly aimed at making Git more friendly
5
5
  Author-email: John Skilleter <john@skilleter.org.uk>
6
6
  Project-URL: Home, https://skilleter.org.uk
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/skilleter_thingy.egg-info/PKG-INFO
5
+ src/skilleter_thingy.egg-info/SOURCES.txt
6
+ src/skilleter_thingy.egg-info/dependency_links.txt
7
+ src/skilleter_thingy.egg-info/entry_points.txt
8
+ src/skilleter_thingy.egg-info/requires.txt
9
+ src/skilleter_thingy.egg-info/top_level.txt
@@ -0,0 +1,43 @@
1
+ [console_scripts]
2
+ addpath = skilleter_thingy:addpath.addpath
3
+ borger = skilleter_thingy:borger.borger
4
+ console_colours = skilleter_thingy:console_colours.console_colours
5
+ diskspacecheck = skilleter_thingy:diskspacecheck.diskspacecheck
6
+ docker-purge = skilleter_thingy:docker_purge.docker_purge
7
+ ffind = skilleter_thingy:ffind.ffind
8
+ ggit = skilleter_thingy:ggit.ggit
9
+ ggrep = skilleter_thingy:ggrep.ggrep
10
+ git-br = skilleter_thingy:git_br.git_br
11
+ git-ca = skilleter_thingy:git_ca.git_ca
12
+ git-cleanup = skilleter_thingy:git_cleanup.git_cleanup
13
+ git-co = skilleter_thingy:git_co.git_co
14
+ git-common = skilleter_thingy:git_common.git_common
15
+ git-hold = skilleter_thingy:git_hold.git_hold
16
+ git-mr = skilleter_thingy:git_mr.git_mr
17
+ git-parent = skilleter_thingy:git_parent.git_parent
18
+ git-review = skilleter_thingy:git_review.git_review
19
+ git-update = skilleter_thingy:git_update.git_update
20
+ git-wt = skilleter_thingy:git_wt.git_wt
21
+ gitcmp-helper = skilleter_thingy:gitcmp_helper.gitcmp_helper
22
+ gitprompt = skilleter_thingy:gitprompt.gitprompt
23
+ gl = skilleter_thingy:gl.gl
24
+ gphotosync = skilleter_thingy:gphotosync.gphotosync
25
+ linecount = skilleter_thingy:linecount.linecount
26
+ moviemover = skilleter_thingy:moviemover.moviemover
27
+ photodupe = skilleter_thingy:photodupe.photodupe
28
+ phototidier = skilleter_thingy:phototidier.phototidier
29
+ py-audit = skilleter_thingy:py_audit.py_audit
30
+ readable = skilleter_thingy:readable.readable
31
+ remdir = skilleter_thingy:remdir.remdir
32
+ rmdupe = skilleter_thingy:rmdupe.rmdupe
33
+ rpylint = skilleter_thingy:rpylint.rpylint
34
+ s3-sync = skilleter_thingy:s3_sync.s3_sync
35
+ splitpics = skilleter_thingy:splitpics.splitpics
36
+ strreplace = skilleter_thingy:strreplace.strreplace
37
+ sysmon = skilleter_thingy:sysmon.sysmon
38
+ tfm = skilleter_thingy:tfm.tfm
39
+ tfparse = skilleter_thingy:tfparse.tfparse
40
+ trimpath = skilleter_thingy:trimpath.trimpath
41
+ window-rename = skilleter_thingy:window_rename.window_rename
42
+ xchmod = skilleter_thingy:xchmod.xchmod
43
+ yamlcheck = skilleter_thingy:yamlcheck.yamlcheck
@@ -1,84 +0,0 @@
1
- [build-system]
2
- requires = ["setuptools>=61.0"]
3
- build-backend = "setuptools.build_meta"
4
-
5
- [project]
6
- name = "skilleter_thingy"
7
-
8
- # Version must be incremented to install updated Thingy
9
-
10
- version = "0.0.38"
11
-
12
- authors = [
13
- {name="John Skilleter", email="john@skilleter.org.uk"},
14
- ]
15
-
16
- description = "A collection of useful utilities, mainly aimed at making Git more friendly"
17
-
18
- readme = "README.md"
19
-
20
- requires-python = ">=3.6"
21
-
22
- classifiers = [
23
- "Programming Language :: Python :: 3",
24
- "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
25
- "Operating System :: OS Independent",
26
- ]
27
-
28
- dependencies = [
29
- "imagehash",
30
- "inotify",
31
- "pillow",
32
- "psutil",
33
- "pyaml",
34
- "pygit2",
35
- "python-dateutil",
36
- "requests",
37
- ]
38
-
39
- [project.urls]
40
- Home = "https://skilleter.org.uk"
41
-
42
- [project.scripts]
43
- addpath = "src:addpath.addpath"
44
- borger = "src:borger.borger"
45
- console_colours = "src:console_colours.console_colours"
46
- diskspacecheck = "src:diskspacecheck.diskspacecheck"
47
- docker-purge = "src:docker_purge.docker_purge"
48
- ffind = "src:ffind.ffind"
49
- ggit = "src:ggit.ggit"
50
- ggrep = "src:ggrep.ggrep"
51
- git-br = "src:git_br.git_br"
52
- git-ca = "src:git_ca.git_ca"
53
- git-cleanup = "src:git_cleanup.git_cleanup"
54
- git-co = "src:git_co.git_co"
55
- git-common = "src:git_common.git_common"
56
- git-hold = "src:git_hold.git_hold"
57
- git-mr = "src:git_mr.git_mr"
58
- git-parent = "src:git_parent.git_parent"
59
- git-review = "src:git_review.git_review"
60
- git-update = "src:git_update.git_update"
61
- git-wt = "src:git_wt.git_wt"
62
- gitcmp-helper = "src:gitcmp_helper.gitcmp_helper"
63
- gitprompt = "src:gitprompt.gitprompt"
64
- gl = "src:gl.gl"
65
- gphotosync = "src:gphotosync.gphotosync"
66
- linecount = "src:linecount.linecount"
67
- moviemover = "src:moviemover.moviemover"
68
- photodupe = "src:photodupe.photodupe"
69
- phototidier = "src:phototidier.phototidier"
70
- py-audit = "src:py_audit.py_audit"
71
- readable = "src:readable.readable"
72
- remdir = "src:remdir.remdir"
73
- rmdupe = "src:rmdupe.rmdupe"
74
- rpylint = "src:rpylint.rpylint"
75
- s3-sync = "src:s3_sync.s3_sync"
76
- splitpics = "src:splitpics.splitpics"
77
- strreplace = "src:strreplace.strreplace"
78
- sysmon = "src:sysmon.sysmon"
79
- tfm = "src:tfm.tfm"
80
- tfparse = "src:tfparse.tfparse"
81
- trimpath = "src:trimpath.trimpath"
82
- window-rename = "src:window_rename.window_rename"
83
- xchmod = "src:xchmod.xchmod"
84
- yamlcheck = "src:yamlcheck.yamlcheck"
@@ -1,6 +0,0 @@
1
- import os
2
- import sys
3
-
4
- thingy_path = os.path.dirname(os.path.realpath(__file__))
5
-
6
- sys.path.append(thingy_path)
@@ -1,107 +0,0 @@
1
- #! /usr/bin/env python3
2
-
3
- ################################################################################
4
- """ Thingy addpath command
5
-
6
- Copyright (C) 2018 John Skilleter
7
-
8
- Update a $PATH-type variable by adding or removing entries.
9
-
10
- Intended to be used as in:
11
-
12
- export PATH=$(addpath $PATH --add /opt/bin)
13
- """
14
- ################################################################################
15
-
16
- import sys
17
- import os
18
- import argparse
19
-
20
- ################################################################################
21
-
22
- def pathmod(pathentries, separator, pathlist, prefix=False, suffix=False, delete=False, force=False):
23
- """ Modify a path.
24
- """
25
-
26
- # Only do something if the list of paths to add exists
27
-
28
- if pathlist:
29
- # Join the list path entries together then split them into individual entries
30
- # Allows for a list of entries in the form ['a:b:c', 'd', 'e']
31
-
32
- paths = separator.join(pathlist).split(separator)
33
-
34
- # Process each entry
35
-
36
- for entry in paths:
37
- # Do nothing (except delete) if the path does not exist and we aren't forcing
38
-
39
- if not entry or (not os.path.isdir(entry) and not (force or delete)):
40
- continue
41
-
42
- # If we are removing or adding/moving an entry remove any existing entry
43
-
44
- if (delete or prefix or suffix) and entry in pathentries:
45
- pathentries.remove(entry)
46
-
47
- # Prefix or suffix the entry
48
-
49
- if not delete and entry not in pathentries:
50
- if suffix:
51
- pathentries.append(entry)
52
- else:
53
- pathentries.insert(0, entry)
54
-
55
- return pathentries
56
-
57
- ################################################################################
58
-
59
- def main():
60
- """ Main function - handles command line, outputs result to stdout """
61
-
62
- parser = argparse.ArgumentParser(description='Add or remove entries from a path list (e.g. as used by the PATH environment variable)')
63
- parser.add_argument('--add', action='append', help='Add an entry to the front of the path (do nothing if it is already present in the path)')
64
- parser.add_argument('--prefix', action='append', help='Add an entry to the front of the path (or move it there if it is already present)')
65
- parser.add_argument('--suffix', action='append', help='Add an entry to the end of the path (or move it there if it is already present)')
66
- parser.add_argument('--remove', action='append', help='Remove an entry from the path (do nothing if it is not present')
67
- parser.add_argument('--force', default=False, help='Add entries even if a corresponding directory does not exist')
68
- parser.add_argument('--separator', action='store', default=':', help='Override the default path separator')
69
- parser.add_argument('path', nargs=1, help='The path to modify')
70
-
71
- args = parser.parse_args()
72
-
73
- # Split the given path into component parts
74
-
75
- pathsplit = [pathentry for pathentry in args.path[0].split(args.separator) if pathentry]
76
-
77
- # Process the additions, suffixations, prefixanisms and deletes.
78
-
79
- pathmod(pathsplit, args.separator, args.add)
80
- pathmod(pathsplit, args.separator, args.prefix, prefix=True)
81
- pathmod(pathsplit, args.separator, args.suffix, suffix=True)
82
- pathmod(pathsplit, args.separator, args.remove, delete=True)
83
-
84
- # Glue the path back together
85
-
86
- pathjoin = args.separator.join(pathsplit)
87
-
88
- # Output the updated path to stdout
89
-
90
- print(pathjoin)
91
-
92
- ################################################################################
93
-
94
- def addpath():
95
- """Entry point"""
96
-
97
- try:
98
- main()
99
- except KeyboardInterrupt:
100
- sys.exit(1)
101
- except BrokenPipeError:
102
- sys.exit(2)
103
-
104
- ################################################################################
105
-
106
- if __name__ == '__main__':
107
- addpath()
@@ -1,269 +0,0 @@
1
- #! /usr/bin/env python3
2
-
3
- """
4
- Wrapper for the borg backup command
5
-
6
- Copyright (C) 2018 John Skilleter
7
-
8
- TODO: Major tidy-up as this is a translation of a Bash script.
9
- TODO: Merge with the usb-backup script since both do almost the same job
10
- TODO: Default configuration file should be named for the hostname
11
- TODO: Move all configuration data into the configuration file
12
- """
13
-
14
- ################################################################################
15
- # Imports
16
-
17
- import sys
18
- import os
19
- import time
20
- import argparse
21
- import configparser
22
- import subprocess
23
- from pathlib import Path
24
-
25
- ################################################################################
26
- # Variables
27
-
28
- DEFAULT_CONFIG_FILE = Path('borger.ini')
29
-
30
- COMMANDS = ('backup', 'mount', 'umount', 'compact', 'info', 'prune', 'check', 'init')
31
-
32
- # TODO: NOT USED
33
- PRUNE_OPTIONS = [
34
- '--keep-within', '7d',
35
- '--keep-daily', '30',
36
- '--keep-weekly', '26',
37
- '--keep-monthly', '24',
38
- '--keep-yearly', '10',
39
- ]
40
-
41
- ################################################################################
42
-
43
- def run(args, cmd):
44
- """Run a subprocess."""
45
-
46
- if args.debug:
47
- cmd_str = ' '.join(cmd)
48
- print(f'Running "{cmd_str}"')
49
-
50
- return subprocess.run(cmd, check=True)
51
-
52
- ################################################################################
53
-
54
- def borg_backup(args, exclude_list):
55
- """Perform a backup."""
56
-
57
- create_options = ['--compression', 'auto,lzma']
58
-
59
- version = time.strftime('%Y-%m-%d-%H:%M:%S')
60
-
61
- print(f'Creating backup version {version}')
62
-
63
- if args.verbose:
64
- create_options += ['--list', '--filter=AMC']
65
-
66
- if args.dryrun:
67
- create_options.append('--dry-run')
68
- else:
69
- create_options.append('--stats')
70
-
71
- exclude_opts = []
72
-
73
- if exclude_list:
74
- for exclude in exclude_list:
75
- exclude_opts += ['--exclude', exclude]
76
-
77
- os.chdir(args.source)
78
-
79
- run(args,
80
- ['borg'] + args.options + ['create', f'{str(args.destination)}::{version}', str(args.source)] + create_options +
81
- ['--show-rc', '--one-file-system', '--exclude-caches'] + exclude_opts)
82
-
83
- ################################################################################
84
-
85
- def borg_prune(args):
86
- """Prune the repo by limiting the number of backups stored."""
87
-
88
- print('Pruning old backups')
89
-
90
- # Keep all backups for at least 7 days, 1 per day for 30 days, 1 per week for 2 years
91
- # 1 per month for 4 years and 1 per year for 10 years.
92
-
93
- run(args, ['borg'] + args.options + ['prune', str(args.destination)] + PRUNE_OPTIONS)
94
-
95
- ################################################################################
96
-
97
- def borg_compact(args):
98
- """Compact the repo."""
99
-
100
- print('Compacting the backup')
101
-
102
- # Keep all backups for at least 7 days, 1 per day for 30 days, 1 per week for 2 years
103
- # 1 per month for 4 years and 1 per year for 10 years.
104
-
105
- run(args, ['borg'] + args.options + ['compact', str(args.destination)])
106
-
107
- ################################################################################
108
-
109
- def borg_info(args):
110
- """Info."""
111
-
112
- run(args, ['borg'] + args.options + ['info', str(args.destination)])
113
-
114
- ################################################################################
115
-
116
- def borg_mount(args):
117
- """Mount."""
118
-
119
- print(f'Mounting Borg backups at {args.mount_dir}')
120
-
121
- mount = Path(args.mount_dir)
122
-
123
- if not mount.is_dir():
124
- mount.mkdir()
125
-
126
- run(args, ['borg'] + args.options + ['mount', str(args.destination), str(mount)])
127
-
128
- ################################################################################
129
-
130
- def borg_umount(args):
131
- """Unmount."""
132
-
133
- print('Unmounting {args.mount}')
134
-
135
- run(args, ['borg'] + args.options + ['umount', str(args.mount)])
136
-
137
- ################################################################################
138
-
139
- def borg_check(args):
140
- """Check the status of a backup."""
141
-
142
- run(args, ['borg'] + args.options + ['check', str(args.destination)])
143
-
144
- ################################################################################
145
-
146
- def borg_init(args):
147
- """Initialise a backup."""
148
-
149
- run(args, ['borg'] + args.options + ['init', str(args.destination), '--encryption=none'])
150
-
151
- ################################################################################
152
-
153
- def process_excludes(exclude_data):
154
- """Process the include list from the configuration file."""
155
-
156
- return exclude_data.replace('%', str(Path.cwd())).split('\n')
157
-
158
- ################################################################################
159
-
160
- def main():
161
- """Entry point."""
162
-
163
- command_list = ', '.join(COMMANDS)
164
-
165
- parser = argparse.ArgumentParser(description='Wrapper app for Borg backup to make it easier to use')
166
- parser.add_argument('--dryrun', '--dry-run', '-D', action='store_true', help='Dry-run comands')
167
- parser.add_argument('--debug', '-d', action='store_true', help='Debug')
168
- parser.add_argument('--verbose', '-v', action='store_true', help='Verbosity to the maximum')
169
- parser.add_argument('--config', '-c', default=None, help='Specify the configuration file')
170
- parser.add_argument('commands', nargs='+', help=f'One or more commands ({command_list})')
171
- args = parser.parse_args()
172
-
173
- # If no config file specified then look in all the usual places
174
-
175
- if args.config:
176
- args.config = Path(args.config)
177
- elif DEFAULT_CONFIG_FILE.is_file():
178
- args.config = DEFAULT_CONFIG_FILE
179
- else:
180
- args.config = Path.home() / DEFAULT_CONFIG_FILE
181
-
182
- if not args.config.is_file():
183
- args.config = Path(sys.argv[0]).parent / DEFAULT_CONFIG_FILE
184
-
185
- # Check that the configuration file exists
186
-
187
- if not args.config.is_file():
188
- print(f'Configuration file "{args.config}" not found')
189
- sys.exit(1)
190
-
191
- # Default options
192
-
193
- args.options = []
194
-
195
- # Read the configuration file
196
-
197
- config = configparser.ConfigParser(interpolation=configparser.ExtendedInterpolation())
198
- config.read(args.config)
199
-
200
- if 'borger' not in config:
201
- print('Invalid configuration file "args.config"')
202
- sys.exit(1)
203
-
204
- exclude = process_excludes(config['borger']['exclude']) if 'exclude' in config['borger'] else []
205
-
206
- if 'prune' in config['borger']:
207
- # TODO: Stuff
208
- print('Parser for the prune option is not implemented yet')
209
- sys.exit(1)
210
-
211
- if 'destination' in config['borger']:
212
- args.destination = config['borger']['destination']
213
- else:
214
- print('Destination directory not specified')
215
- sys.exit(1)
216
-
217
- if 'source' in config['borger']:
218
- args.source = Path(config['borger']['source'])
219
- else:
220
- print('Source directory not specified')
221
- sys.exit(1)
222
-
223
- # Initialise if necessary
224
-
225
- if args.debug:
226
- args.options.append('--verbose')
227
-
228
- if args.verbose:
229
- args.options.append('--progress')
230
-
231
- # Decide what to do
232
-
233
- for command in args.commands:
234
- if command == 'backup':
235
- borg_backup(args, exclude)
236
- elif command == 'mount':
237
- borg_mount(args)
238
- elif command == 'umount':
239
- borg_umount(args)
240
- elif command == 'info':
241
- borg_info(args)
242
- elif command == 'prune':
243
- borg_prune(args)
244
- elif command == 'check':
245
- borg_check(args)
246
- elif command == 'init':
247
- borg_init(args)
248
- elif command == 'compact':
249
- borg_compact(args)
250
- else:
251
- print(f'Unrecognized command: {command}')
252
- sys.exit(2)
253
-
254
- ################################################################################
255
-
256
- def borger():
257
- """Entry point"""
258
-
259
- try:
260
- main()
261
- except KeyboardInterrupt:
262
- sys.exit(1)
263
- except BrokenPipeError:
264
- sys.exit(2)
265
-
266
- ################################################################################
267
-
268
- if __name__ == '__main__':
269
- borger()
@@ -1,63 +0,0 @@
1
- #! /usr/bin/env python3
2
-
3
- ################################################################################
4
- """ Output all console colours
5
-
6
- Copyright (C) 2017-18 John Skilleter
7
-
8
- Licence: GPL v3 or later
9
- """
10
- ################################################################################
11
-
12
- import sys
13
-
14
- import thingy.colour as colour
15
-
16
- ################################################################################
17
-
18
- def main():
19
- """ Main function - draw the colour grid """
20
-
21
- # Extended ANSI colour are slightly weird.
22
- # Colours 0-15 are the standard basic colours
23
- # Colours 16-231 form a 6x6x6 colour cube
24
- # Colours 232-255 are greyscale range with colours 0 and 15 as black and white
25
-
26
- for code in range(0, 256):
27
- if code in (8, 16) or (code > 16 and (code - 16) % 6 == 0):
28
- colour.write('')
29
-
30
- if (code - 16) % 36 == 0:
31
- colour.write('')
32
-
33
- # Set the foreground code to be white for dark backgrounds
34
-
35
- foreground = 15 if code in (0, 1, 4, 5, 8, 12) \
36
- or (16 <= code <= 33) \
37
- or (52 <= code <= 69) \
38
- or (88 <= code <= 105) \
39
- or (124 <= code <= 135) \
40
- or (160 <= code <= 171) \
41
- or (196 <= code <= 201) \
42
- or (232 <= code <= 243) else 0
43
-
44
- colour.write('[B%d][%d] %3d [NORMAL] ' % (code, foreground, code), newline=False)
45
-
46
- print()
47
-
48
- ################################################################################
49
-
50
- def console_colours():
51
- """Entry point"""
52
-
53
- try:
54
- main()
55
- except KeyboardInterrupt:
56
- sys.exit(1)
57
- except BrokenPipeError:
58
- sys.exit(2)
59
-
60
- ################################################################################
61
-
62
- if __name__ == '__main__':
63
- console_colours()