write_when_new, gitea, ifup/ifdown
- create parent directory with root access, if needed - omit gitea check when repo is not available - replace 'ifup <net> by ifconfig <net> up'
This commit is contained in:
6
gitea.py
6
gitea.py
@@ -86,7 +86,11 @@ def change_to_gitea(doit, *repos):
|
||||
cwd = os.getcwd()
|
||||
try:
|
||||
for repo in repos:
|
||||
os.chdir(Path('~').expanduser() / repo)
|
||||
repodir = Path('~').expanduser() / repo
|
||||
if not repodir.is_dir():
|
||||
print(repodir, 'does not exist')
|
||||
continue
|
||||
os.chdir(repodir)
|
||||
try:
|
||||
parser = ConfigParser()
|
||||
parser.read('.git/config')
|
||||
|
||||
@@ -32,6 +32,8 @@ try:
|
||||
import serial
|
||||
except ImportError:
|
||||
if 'yes'.startswith(input('install pyserial? [y]')):
|
||||
os.system('sudo apt update')
|
||||
os.system('sudo apt install python3-pip')
|
||||
os.system('sudo pip3 install --break-system-packages pyserial')
|
||||
serial = None
|
||||
|
||||
@@ -311,7 +313,7 @@ def write_when_new(filename, content, as_root=False, ignore_reduction=False):
|
||||
return False
|
||||
if doit:
|
||||
if lines:
|
||||
Path(filename).parent.mkdir(parents=True, exist_ok=True)
|
||||
unix_cmd(f'mkdir -p {Path(filename).parent}', sudo=as_root)
|
||||
with tempfile.NamedTemporaryFile('w') as fil:
|
||||
fil.write(content)
|
||||
fil.flush()
|
||||
@@ -702,10 +704,10 @@ def handle_config():
|
||||
for service, (action, _) in to_start.items():
|
||||
show.dirty = True
|
||||
if action == 'if_restart':
|
||||
do_cmd(f'ifdown {service}')
|
||||
do_cmd(f'ifconfig {service} down')
|
||||
for service, (action, as_root) in to_start.items():
|
||||
if action == 'if_restart':
|
||||
do_cmd(f'ifup {service}')
|
||||
do_cmd(f'ifconfig {service} up')
|
||||
else:
|
||||
if action == 'restart': # else 'enable'
|
||||
do_cmd('systemctl', 'restart', service, sudo=as_root)
|
||||
|
||||
Reference in New Issue
Block a user