skilleter-thingy 0.3.0__py3-none-any.whl → 0.3.1__py3-none-any.whl

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.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: skilleter_thingy
3
- Version: 0.3.0
3
+ Version: 0.3.1
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
@@ -407,24 +407,6 @@ Add or remove entries from a path list (e.g. as used by the PATH environment var
407
407
 
408
408
  Display all available colours in the console.
409
409
 
410
- ## docker-purge
411
-
412
- Stop or kill docker instances and/or remove docker images.
413
-
414
- docker-purge [-h] [--stop] [--kill] [--remove] [--list] [--force] [--debug] [images ...]
415
-
416
- positional arguments:
417
- images List of Docker containers (regular expression)
418
-
419
- options:
420
- -h, --help show this help message and exit
421
- --stop, -s Stop Docker instances
422
- --kill, -k Kill Docker instances
423
- --remove, -r Remove Docker images
424
- --list, -l List what would be done without doing it
425
- --force, -f Forcibly kill/remove instances
426
- --debug Enable debug output
427
-
428
410
  ## ffind
429
411
 
430
412
  Simple file find utility - replaces the `find` command with something that is more human-friendly.
@@ -1,7 +1,6 @@
1
1
  skilleter_thingy/__init__.py,sha256=rVPTxm8L5w52U0YdTd7r_D44SBP7pS3JCJtsf0iIsow,110
2
2
  skilleter_thingy/addpath.py,sha256=4Yhhgjjz1XDI98j0dAiQpNA2ejLefeWUTeSg3nIXQq0,3842
3
3
  skilleter_thingy/console_colours.py,sha256=BOS9mo3jChx_FE8L1j488MDoVNgib11KjTRhrz_YRYE,1781
4
- skilleter_thingy/docker_purge.py,sha256=6vIZmSHd8ik1mvLICekjvrTz4A7h2S74QeafZ--GvUU,3331
5
4
  skilleter_thingy/ffind.py,sha256=kIMx3VDvNpvTbp0gDzsiOiSlV_R8xZowHxADjts9qI0,19571
6
5
  skilleter_thingy/ggit.py,sha256=BL-DhNcz4Nd3sA-3Kl6gZ-zFtbNqOpyufvas-0aD8nk,2465
7
6
  skilleter_thingy/ggrep.py,sha256=fnTzOI1Qbf7IY_TnStdx5uqeUhqSDkapxmhYgrONJHw,5887
@@ -37,7 +36,6 @@ skilleter_thingy/thingy/dc_curses.py,sha256=fuuQPR11zV_akAhygL_cAhVLC5YAgKgowzlI
37
36
  skilleter_thingy/thingy/dc_defaults.py,sha256=ahcteQvoWZrO5iTU68zkIY1Zex6iX5uR5ubwI4CCYBk,6170
38
37
  skilleter_thingy/thingy/dc_util.py,sha256=Df73imXhHx3HzcPHiRcHAoea0e3HURdLcrolUsMhOFs,1783
39
38
  skilleter_thingy/thingy/dircolors.py,sha256=aBcq9ci855GSOIjrZWm8kG0ksCodvUmc4FlIOEOyBcA,12292
40
- skilleter_thingy/thingy/docker.py,sha256=6F6SewGMNk6FV_UICJuEGeyU5bqF-NRN9FHCefKNDNA,2790
41
39
  skilleter_thingy/thingy/files.py,sha256=nFIOEi2rl2SuYa6Zd7Nf1BWCKyKlF8D6hsbPlfnVefQ,4791
42
40
  skilleter_thingy/thingy/git.py,sha256=AIPPhEg1KU98milewP_vazxDUVat3QFQUsK9cqmdsEw,43234
43
41
  skilleter_thingy/thingy/gitlab.py,sha256=uXAF918xnPk6qQyiwPQDbMZfqtJzhiRqDS7yEtJEIAg,6079
@@ -47,9 +45,9 @@ skilleter_thingy/thingy/run.py,sha256=Q6uug_LucKbn36RB-r08QYaCzmeoU452ipzQ2YiVUP
47
45
  skilleter_thingy/thingy/tfm_pane.py,sha256=XTTpSm71CyQyGmlVLuCthioOwech0jhUiFUXb-chS_Q,19792
48
46
  skilleter_thingy/thingy/tidy.py,sha256=AQ2RawsZJg6WHrgayi_ZptFL9occ7suSdCHbU3P-cys,5971
49
47
  skilleter_thingy/thingy/venv_template.py,sha256=ZfUvi8qFNGrk7J030Zy57xjwMtfIArJyqa-MqafyjVk,1016
50
- skilleter_thingy-0.3.0.dist-info/licenses/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
51
- skilleter_thingy-0.3.0.dist-info/METADATA,sha256=pSxW_v8FMf_sluaynVivXZ59memjX-fGYptHD9hg77c,30134
52
- skilleter_thingy-0.3.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
53
- skilleter_thingy-0.3.0.dist-info/entry_points.txt,sha256=nqNYc__bq5Dl9SgXktajdqxpFkEAUVDkxh8dNFjDP9A,1507
54
- skilleter_thingy-0.3.0.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
55
- skilleter_thingy-0.3.0.dist-info/RECORD,,
48
+ skilleter_thingy-0.3.1.dist-info/licenses/LICENSE,sha256=ljOS4DjXvqEo5VzGfdaRwgRZPbNScGBmfwyC8PChvmQ,32422
49
+ skilleter_thingy-0.3.1.dist-info/METADATA,sha256=J9OlzotB7aCdrmYT7Kl0dP-9Oj7BzzBpQVS7kmoweJ0,29526
50
+ skilleter_thingy-0.3.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
51
+ skilleter_thingy-0.3.1.dist-info/entry_points.txt,sha256=GVZW2krSQlttxWWkym-ZCc4W0nV97gaqtFi-emcvQMk,1449
52
+ skilleter_thingy-0.3.1.dist-info/top_level.txt,sha256=8-JhgToBBiWURunmvfpSxEvNkDHQQ7r25-aBXtZv61g,17
53
+ skilleter_thingy-0.3.1.dist-info/RECORD,,
@@ -1,7 +1,6 @@
1
1
  [console_scripts]
2
2
  addpath = skilleter_thingy:addpath.addpath
3
3
  consolecolours = skilleter_thingy:console_colours.console_colours
4
- docker-purge = skilleter_thingy:docker_purge.docker_purge
5
4
  ffind = skilleter_thingy:ffind.ffind
6
5
  ggit = skilleter_thingy:ggit.ggit
7
6
  ggrep = skilleter_thingy:ggrep.ggrep
@@ -1,112 +0,0 @@
1
- #! /usr/bin/env python3
2
-
3
- ################################################################################
4
- """ Thingy docker-purge command
5
-
6
- Copyright (C) 2017 John Skilleter
7
-
8
- Initial version - contains only basic error checking and limited debug output.
9
- """
10
- ################################################################################
11
-
12
- import sys
13
- import re
14
- import argparse
15
- import logging
16
-
17
- from thingy import docker
18
-
19
- ################################################################################
20
-
21
- def initialise():
22
- """ Parse the command line """
23
-
24
- breakpoint()
25
- parser = argparse.ArgumentParser(description='Purge docker instances and images')
26
-
27
- parser.add_argument('--stop', '-s', action='store_true', help='Stop Docker instances')
28
- parser.add_argument('--kill', '-k', action='store_true', help='Kill Docker instances')
29
- parser.add_argument('--remove', '-r', action='store_true', help='Remove Docker images')
30
- parser.add_argument('--list', '-l', action='store_true', help='List what would be done without doing it')
31
- parser.add_argument('--force', '-f', action='store_true', help='Forcibly kill/remove instances')
32
- parser.add_argument('--debug', action='store_true', help='Enable debug output')
33
- parser.add_argument('images', nargs='*', help='List of Docker containers (regular expression)')
34
-
35
- args = parser.parse_args()
36
-
37
- # Configure logging
38
-
39
- if args.debug:
40
- logging.basicConfig(level=logging.DEBUG)
41
- logging.info('Debug logging enabled')
42
-
43
- # Default is to stop matching images
44
-
45
- if not args.stop and not args.kill and not args.remove:
46
- args.stop = True
47
-
48
- # Default is to match all containers
49
-
50
- if not args.images:
51
- args.images = '.*'
52
- else:
53
- args.images = '|'.join(args.images)
54
-
55
- logging.info('Arguments: %s', args)
56
- return args
57
-
58
- ################################################################################
59
-
60
- def main(args):
61
- """ Main code """
62
-
63
- try:
64
- if args.stop or args.kill:
65
- for instance in docker.instances():
66
- if re.match(args.images, instance):
67
-
68
- print(f'Stopping instance: {instance}')
69
-
70
- if not args.list:
71
- docker.stop(instance, force=args.force)
72
-
73
- if args.kill:
74
- for instance in docker.instances(all=True):
75
- if re.match(args.images, instance):
76
-
77
- print(f'Removing instance: {instance}')
78
-
79
- if not args.list:
80
- docker.rm(instance)
81
-
82
- if args.remove:
83
- for image in docker.images():
84
- if re.match(args.images, image):
85
-
86
- print(f'Removing image: {image}')
87
-
88
- if not args.list:
89
- docker.rmi(image, force=args.force)
90
-
91
- except docker.DockerError as exc:
92
- sys.stderr.write(f'{str(exc)}\n')
93
- sys.exit(1)
94
-
95
- ################################################################################
96
-
97
- def docker_purge():
98
- """Entry point"""
99
-
100
- try:
101
- config = initialise()
102
- main(config)
103
-
104
- except KeyboardInterrupt:
105
- sys.exit(1)
106
- except BrokenPipeError:
107
- sys.exit(2)
108
-
109
- ################################################################################
110
-
111
- if __name__ == '__main__':
112
- docker_purge()
@@ -1,105 +0,0 @@
1
- #! /usr/bin/env python3
2
-
3
- ################################################################################
4
- """ Docker interface for Thingy
5
-
6
- Copyright (C) 2017 John Skilleter
7
-
8
- Note that this:
9
- * Only implements functions required by docker-purge
10
- * Only has basic error checking, in that it raises DockerError
11
- for any error returned by the external docker command.
12
- """
13
- ################################################################################
14
-
15
- import subprocess
16
-
17
- ################################################################################
18
-
19
- class DockerError(Exception):
20
- """ Exception for dockery things """
21
-
22
- pass
23
-
24
- ################################################################################
25
-
26
- def instances(all=False):
27
- """ Return a list of all current Docker instances """
28
-
29
- cmd = ['docker', 'ps', '-q']
30
-
31
- if all:
32
- cmd.append('-a')
33
-
34
- instances_list = []
35
- try:
36
- process = subprocess.run(cmd, capture_output=True, check=True, text=True)
37
-
38
- for result in process.stdout:
39
- instances_list.append(result)
40
-
41
- except subprocess.CalledProcessError as exc:
42
- raise DockerError(exc)
43
-
44
- return instances_list
45
-
46
- ################################################################################
47
-
48
- def stop(instance, force=False):
49
- """ Stop the specified Docker instance """
50
-
51
- # TODO: force option not implemented
52
-
53
- try:
54
- subprocess.run(['docker', 'stop', instance], check=True, capture_output=False)
55
-
56
- except suprocess.CalledProcessError as exc:
57
- raise DockerError(exc)
58
-
59
- ################################################################################
60
-
61
- def rm(instance, force=False):
62
- """ Remove the specified instance """
63
-
64
- cmd = ['docker', 'rm']
65
-
66
- if force:
67
- cmd.append('--force')
68
-
69
- cmd.append(instance)
70
-
71
- try:
72
- subprocess.run(cmd, check=True, capture_output=False)
73
-
74
- except subprocess.CalledProcessError as exc:
75
- raise DockerError(exc)
76
-
77
- ################################################################################
78
-
79
- def images():
80
- """ Return a list of all current Docker images """
81
-
82
- try:
83
- process = subprocess.run(['docker', 'images', '-q'], capture_output=True, check=True)
84
-
85
- for result in process:
86
- yield result
87
-
88
- except subprocess.CalledProcessError as exc:
89
- raise DockerError(exc)
90
-
91
- ################################################################################
92
-
93
- def rmi(image, force=False):
94
- """ Remove the specified image """
95
-
96
- cmd = ['docker', 'rmi']
97
- if force:
98
- cmd.append('--force')
99
-
100
- cmd.append(image)
101
-
102
- try:
103
- subprocess.run(cmd, capture_output=False, check=True)
104
- except subprocess.CalledProcessError as exc:
105
- raise DockerError(exc)