chibi-command 2.3.2__tar.gz → 2.4.0__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.
- {chibi_command-2.3.2 → chibi_command-2.4.0}/HISTORY.rst +9 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/PKG-INFO +26 -3
- {chibi_command-2.3.2 → chibi_command-2.4.0}/README.rst +16 -2
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/__init__.py +18 -4
- chibi_command-2.4.0/chibi_command/archilinux/pacman.py +61 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/disk/lsblk.py +1 -5
- chibi_command-2.4.0/chibi_command/unittests/__init__.py +23 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command.egg-info/PKG-INFO +26 -3
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command.egg-info/SOURCES.txt +1 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/setup.cfg +1 -1
- {chibi_command-2.3.2 → chibi_command-2.4.0}/setup.py +1 -1
- chibi_command-2.3.2/chibi_command/archilinux/pacman.py +0 -18
- {chibi_command-2.3.2 → chibi_command-2.4.0}/AUTHORS.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/CONTRIBUTING.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/LICENSE +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/MANIFEST.in +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/archilinux/__init__.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/archilinux/yay.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/centos/__init__.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/centos/dnf.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/centos/iptable.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/centos/yum.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/common.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/db.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/dd.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/disk/__init__.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/disk/dd.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/disk/e2label.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/disk/format.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/disk/mount.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/echo.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/ffmpeg.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/file.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/image/__init__.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/image/convert.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/image/qr.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/lxc/__init__.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/lxc/delegate.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/lxc/lxc.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/mpd.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/network/__init__.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/network/ifconfig.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/network/interfaces.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/network/iwconfig.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/network/nmap.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/network/nmcli.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/nix/__init__.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/nix/locale.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/nix/systemd.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/nix/systemd_run.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/nix/user.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/qr.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/rabbitmq.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/rpm.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/rsync.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/ssh.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/sysctl.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/wmctrl.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command/xfce4.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command.egg-info/dependency_links.txt +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command.egg-info/not-zip-safe +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command.egg-info/requires.txt +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/chibi_command.egg-info/top_level.txt +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/Makefile +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/authors.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/conf.py +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/contributing.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/history.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/index.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/installation.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/make.bat +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/readme.rst +0 -0
- {chibi_command-2.3.2 → chibi_command-2.4.0}/docs/usage.rst +0 -0
|
@@ -2,6 +2,15 @@
|
|
|
2
2
|
History
|
|
3
3
|
=======
|
|
4
4
|
|
|
5
|
+
********************
|
|
6
|
+
2.4.0 ( 2026-03-25 )
|
|
7
|
+
********************
|
|
8
|
+
|
|
9
|
+
* se agrego atajo para parchear popen
|
|
10
|
+
* se agrego parametro en las clases para agregar variables de ambiente cuando
|
|
11
|
+
se ejecuta algun comando
|
|
12
|
+
* se agrego funcion para buscar paquetes con pacman
|
|
13
|
+
|
|
5
14
|
********************
|
|
6
15
|
2.3.2 ( 2026-03-24 )
|
|
7
16
|
********************
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chibi_command
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: run terminal commands
|
|
5
5
|
Home-page: https://github.com/dem4ply/chibi_command
|
|
6
6
|
Author: Dem4ply
|
|
@@ -65,6 +65,7 @@ Use
|
|
|
65
65
|
***
|
|
66
66
|
|
|
67
67
|
use lsblk
|
|
68
|
+
=========
|
|
68
69
|
|
|
69
70
|
.. code-block:: python
|
|
70
71
|
|
|
@@ -74,14 +75,36 @@ use lsblk
|
|
|
74
75
|
assert blocks[ 'sda' ].childs[ 'name' ]
|
|
75
76
|
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
parchear popen
|
|
79
|
+
==============
|
|
80
|
+
|
|
81
|
+
.. code-block:: python
|
|
82
|
+
|
|
83
|
+
from chibi_command import Command, Command_json_result
|
|
84
|
+
from chibi_command.unittests import patch_empty
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Test_test( TestCase ):
|
|
88
|
+
|
|
89
|
+
@patch_empty
|
|
90
|
+
def test_some_test( self, popen ):
|
|
91
|
+
self.command().run()
|
|
92
|
+
popen.assert_called()
|
|
79
93
|
|
|
80
94
|
|
|
81
95
|
=======
|
|
82
96
|
History
|
|
83
97
|
=======
|
|
84
98
|
|
|
99
|
+
********************
|
|
100
|
+
2.4.0 ( 2026-03-25 )
|
|
101
|
+
********************
|
|
102
|
+
|
|
103
|
+
* se agrego atajo para parchear popen
|
|
104
|
+
* se agrego parametro en las clases para agregar variables de ambiente cuando
|
|
105
|
+
se ejecuta algun comando
|
|
106
|
+
* se agrego funcion para buscar paquetes con pacman
|
|
107
|
+
|
|
85
108
|
********************
|
|
86
109
|
2.3.2 ( 2026-03-24 )
|
|
87
110
|
********************
|
|
@@ -25,6 +25,7 @@ Use
|
|
|
25
25
|
***
|
|
26
26
|
|
|
27
27
|
use lsblk
|
|
28
|
+
=========
|
|
28
29
|
|
|
29
30
|
.. code-block:: python
|
|
30
31
|
|
|
@@ -34,5 +35,18 @@ use lsblk
|
|
|
34
35
|
assert blocks[ 'sda' ].childs[ 'name' ]
|
|
35
36
|
|
|
36
37
|
|
|
37
|
-
|
|
38
|
-
|
|
38
|
+
parchear popen
|
|
39
|
+
==============
|
|
40
|
+
|
|
41
|
+
.. code-block:: python
|
|
42
|
+
|
|
43
|
+
from chibi_command import Command, Command_json_result
|
|
44
|
+
from chibi_command.unittests import patch_empty
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class Test_test( TestCase ):
|
|
48
|
+
|
|
49
|
+
@patch_empty
|
|
50
|
+
def test_some_test( self, popen ):
|
|
51
|
+
self.command().run()
|
|
52
|
+
popen.assert_called()
|
|
@@ -7,7 +7,7 @@ import logging
|
|
|
7
7
|
|
|
8
8
|
__author__ = """dem4ply"""
|
|
9
9
|
__email__ = 'dem4ply@gmail.com'
|
|
10
|
-
__version__ = '2.
|
|
10
|
+
__version__ = '2.4.0'
|
|
11
11
|
|
|
12
12
|
logger = logging.getLogger( 'chibi.command' )
|
|
13
13
|
|
|
@@ -78,10 +78,11 @@ class Command:
|
|
|
78
78
|
result_class = Command_result
|
|
79
79
|
delegate = None
|
|
80
80
|
raise_on_fail = True
|
|
81
|
+
env = None
|
|
81
82
|
|
|
82
83
|
def __init__(
|
|
83
84
|
self, *args, captive=None, command=None, result_class=None,
|
|
84
|
-
delegate=None, **kw ):
|
|
85
|
+
delegate=None, env=None, **kw ):
|
|
85
86
|
|
|
86
87
|
if delegate is not None:
|
|
87
88
|
self.delegate = delegate
|
|
@@ -98,6 +99,12 @@ class Command:
|
|
|
98
99
|
if not command and not self.command and args:
|
|
99
100
|
self.command = args[0]
|
|
100
101
|
args = args[1:]
|
|
102
|
+
|
|
103
|
+
if env is not None:
|
|
104
|
+
self.env = Chibi_atlas( env )
|
|
105
|
+
else:
|
|
106
|
+
self.env = Chibi_atlas( self.env )
|
|
107
|
+
|
|
101
108
|
if self.args is None:
|
|
102
109
|
self.args = tuple()
|
|
103
110
|
else:
|
|
@@ -128,8 +135,15 @@ class Command:
|
|
|
128
135
|
arguments = self.build_tuple( *args, **kw )
|
|
129
136
|
logger.debug( f'tuplas del comando: "{str(arguments)}"' )
|
|
130
137
|
arguments = tuple( map( lambda x: str( x ), arguments ) )
|
|
131
|
-
|
|
132
|
-
|
|
138
|
+
if self.env:
|
|
139
|
+
proc = Popen(
|
|
140
|
+
arguments, stdin=stdin,
|
|
141
|
+
stdout=self.stdout, stderr=self.stderr,
|
|
142
|
+
env=self.env )
|
|
143
|
+
else:
|
|
144
|
+
proc = Popen(
|
|
145
|
+
arguments, stdin=stdin,
|
|
146
|
+
stdout=self.stdout, stderr=self.stderr, )
|
|
133
147
|
return proc
|
|
134
148
|
|
|
135
149
|
def build_tuple( self, *args, **kw ):
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
from chibi_atlas import Chibi_atlas
|
|
2
|
+
from chibi_command import Command, Command_result
|
|
3
|
+
from chibi_hybrid import Chibi_hybrid
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def join_parted_lines( lines ):
|
|
7
|
+
prev = next( lines )
|
|
8
|
+
for line in lines:
|
|
9
|
+
if line.startswith( ' ' ):
|
|
10
|
+
prev = f"{prev}\n{line}"
|
|
11
|
+
else:
|
|
12
|
+
yield prev
|
|
13
|
+
prev = line
|
|
14
|
+
yield prev
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Query_result( Command_result ):
|
|
18
|
+
def parse_result( self ):
|
|
19
|
+
if not bool( self ):
|
|
20
|
+
return
|
|
21
|
+
lines = self.result.split( '\n' )
|
|
22
|
+
lines = filter( bool, lines )
|
|
23
|
+
lines = join_parted_lines( lines )
|
|
24
|
+
tuples = ( line.split( ':', 1 ) for line in lines )
|
|
25
|
+
tuples = ( ( k.strip().lower(), v.strip() ) for k, v in tuples )
|
|
26
|
+
result = Chibi_atlas( dict( tuples ) )
|
|
27
|
+
self.result = result
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
class Pacman( Command ):
|
|
31
|
+
command = 'pacman'
|
|
32
|
+
captive = False
|
|
33
|
+
|
|
34
|
+
@classmethod
|
|
35
|
+
def sync( cls ):
|
|
36
|
+
return cls( '-Sy' )
|
|
37
|
+
|
|
38
|
+
@classmethod
|
|
39
|
+
def upgrade( cls ):
|
|
40
|
+
return cls( '-Syu' )
|
|
41
|
+
|
|
42
|
+
@classmethod
|
|
43
|
+
def install( cls, *packages ):
|
|
44
|
+
return cls( '-S', *packages )
|
|
45
|
+
|
|
46
|
+
@classmethod
|
|
47
|
+
def query( cls ):
|
|
48
|
+
return cls( '-Q' )
|
|
49
|
+
|
|
50
|
+
@Chibi_hybrid
|
|
51
|
+
def info( cls, package ):
|
|
52
|
+
return cls.query().info( package )
|
|
53
|
+
|
|
54
|
+
@info.instancemethod
|
|
55
|
+
def info( self, package ):
|
|
56
|
+
self.add_args( '-i', package )
|
|
57
|
+
self.env.LC_ALL = 'C'
|
|
58
|
+
self.result_class = Query_result
|
|
59
|
+
self.captive = True
|
|
60
|
+
self.raise_on_fail = False
|
|
61
|
+
return self
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
from unittest.mock import patch, Mock
|
|
2
|
+
import functools
|
|
3
|
+
import logging
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger( 'chibi_command.unittests' )
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def patch_empty( func, target='chibi_command.Popen' ):
|
|
10
|
+
"""
|
|
11
|
+
decorador para parchear la funcion Popen de chibi command
|
|
12
|
+
"""
|
|
13
|
+
@functools.wraps( func )
|
|
14
|
+
def wrapper( *args, **kw ):
|
|
15
|
+
patcher = patch( target )
|
|
16
|
+
with patcher as popen:
|
|
17
|
+
proccess = Mock()
|
|
18
|
+
popen.return_value = proccess
|
|
19
|
+
proccess.returncode = 0
|
|
20
|
+
proccess.communicate.return_value = ( b"", b"" )
|
|
21
|
+
|
|
22
|
+
func( *args, popen, **kw )
|
|
23
|
+
return wrapper
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: chibi_command
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.4.0
|
|
4
4
|
Summary: run terminal commands
|
|
5
5
|
Home-page: https://github.com/dem4ply/chibi_command
|
|
6
6
|
Author: Dem4ply
|
|
@@ -65,6 +65,7 @@ Use
|
|
|
65
65
|
***
|
|
66
66
|
|
|
67
67
|
use lsblk
|
|
68
|
+
=========
|
|
68
69
|
|
|
69
70
|
.. code-block:: python
|
|
70
71
|
|
|
@@ -74,14 +75,36 @@ use lsblk
|
|
|
74
75
|
assert blocks[ 'sda' ].childs[ 'name' ]
|
|
75
76
|
|
|
76
77
|
|
|
77
|
-
|
|
78
|
-
|
|
78
|
+
parchear popen
|
|
79
|
+
==============
|
|
80
|
+
|
|
81
|
+
.. code-block:: python
|
|
82
|
+
|
|
83
|
+
from chibi_command import Command, Command_json_result
|
|
84
|
+
from chibi_command.unittests import patch_empty
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
class Test_test( TestCase ):
|
|
88
|
+
|
|
89
|
+
@patch_empty
|
|
90
|
+
def test_some_test( self, popen ):
|
|
91
|
+
self.command().run()
|
|
92
|
+
popen.assert_called()
|
|
79
93
|
|
|
80
94
|
|
|
81
95
|
=======
|
|
82
96
|
History
|
|
83
97
|
=======
|
|
84
98
|
|
|
99
|
+
********************
|
|
100
|
+
2.4.0 ( 2026-03-25 )
|
|
101
|
+
********************
|
|
102
|
+
|
|
103
|
+
* se agrego atajo para parchear popen
|
|
104
|
+
* se agrego parametro en las clases para agregar variables de ambiente cuando
|
|
105
|
+
se ejecuta algun comando
|
|
106
|
+
* se agrego funcion para buscar paquetes con pacman
|
|
107
|
+
|
|
85
108
|
********************
|
|
86
109
|
2.3.2 ( 2026-03-24 )
|
|
87
110
|
********************
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
from chibi_command import Command
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class Pacman( Command ):
|
|
5
|
-
command = 'pacman'
|
|
6
|
-
captive = False
|
|
7
|
-
|
|
8
|
-
@classmethod
|
|
9
|
-
def sync( cls ):
|
|
10
|
-
return cls( '-Sy' )
|
|
11
|
-
|
|
12
|
-
@classmethod
|
|
13
|
-
def upgrade( cls ):
|
|
14
|
-
return cls( '-Syu' )
|
|
15
|
-
|
|
16
|
-
@classmethod
|
|
17
|
-
def install( cls, *packages ):
|
|
18
|
-
return cls( '-S', *packages )
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
File without changes
|