mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
fix formatting issues
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
fa74a26042
commit
eb83e00011
134 files changed
+598
-720
No files matched your search
+5
-4
@@ -109,8 +109,9 @@ def subcommand_generate_ticket(arguments):
|
||||
pkey = crypto.load_privatekey(crypto.FILETYPE_PEM, fil.read().encode())
|
||||
valid_until = minutes_from_now(12 * 60)
|
||||
grace_period = minutes_from_now(11 * 60)
|
||||
print(create_ticket(pkey, uid, valid_until, tokens=tokens,
|
||||
graceperiod=grace_period))
|
||||
print(
|
||||
create_ticket(pkey, uid, valid_until, tokens=tokens,
|
||||
graceperiod=grace_period))
|
||||
|
||||
|
||||
def minutes_from_now(minutes):
|
||||
@@ -120,8 +121,8 @@ def minutes_from_now(minutes):
|
||||
|
||||
def seconds_from_now(seconds):
|
||||
"""Return a timestamp at the given number of seconds from now."""
|
||||
return (
|
||||
datetime.datetime.now() + datetime.timedelta(0, seconds)).timestamp()
|
||||
return (datetime.datetime.now() +
|
||||
datetime.timedelta(0, seconds)).timestamp()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
+2
-2
@@ -66,8 +66,8 @@ def subcommand_reset_home_page(_):
|
||||
config_file = FREEDOMBOX_APACHE_CONFIG
|
||||
default_path = 'plinth'
|
||||
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Httpd/lens', 'Httpd.lns')
|
||||
aug.set('/augeas/load/Httpd/incl[last() + 1]', config_file)
|
||||
aug.load()
|
||||
|
||||
+2
-2
@@ -72,8 +72,8 @@ def set_domain_name(domain_name):
|
||||
# {'url': domain_name})
|
||||
# Manually changing the domain name in the conf files.
|
||||
conf_file = '/etc/diaspora.conf'
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
|
||||
# lens for shell-script config file
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
|
||||
+5
-4
@@ -62,8 +62,9 @@ def parse_arguments():
|
||||
# Add a service
|
||||
add_service = subparsers.add_parser('add-service', help='Add a service')
|
||||
add_service.add_argument('service', help='Name of the service to add')
|
||||
add_service.add_argument(
|
||||
'--zone', help='Zone to which service is to be added', required=True)
|
||||
add_service.add_argument('--zone',
|
||||
help='Zone to which service is to be added',
|
||||
required=True)
|
||||
|
||||
# Remove a service status
|
||||
remove_service = subparsers.add_parser('remove-service',
|
||||
@@ -111,8 +112,8 @@ def _flush_iptables_rules():
|
||||
def set_firewall_backend(backend):
|
||||
"""Set FirewallBackend attribute to the specified string."""
|
||||
conf_file = '/etc/firewalld/firewalld.conf'
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
|
||||
# lens for shell-script config file
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
|
||||
+3
-4
@@ -38,7 +38,6 @@ logger = logging.getLogger(__name__)
|
||||
|
||||
class ValidateRepoName(argparse.Action):
|
||||
"""Validate a repository name and add .git extension if necessary."""
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
RepositoryValidator()(values)
|
||||
if not values.endswith('.git'):
|
||||
@@ -48,7 +47,6 @@ class ValidateRepoName(argparse.Action):
|
||||
|
||||
class ValidateRepoUrl(argparse.Action):
|
||||
"""Validate a repository URL."""
|
||||
|
||||
def __call__(self, parser, namespace, values, option_string=None):
|
||||
RepositoryValidator(input_should_be='url')(values)
|
||||
setattr(namespace, self.dest, values)
|
||||
@@ -359,8 +357,9 @@ def subcommand_repo_info(arguments):
|
||||
|
||||
print(
|
||||
json.dumps(
|
||||
dict(name=arguments.name[:-4], description=_get_repo_description(
|
||||
arguments.name), owner=_get_repo_owner(arguments.name),
|
||||
dict(name=arguments.name[:-4],
|
||||
description=_get_repo_description(arguments.name),
|
||||
owner=_get_repo_owner(arguments.name),
|
||||
access=_get_access_status(arguments.name))))
|
||||
|
||||
|
||||
|
||||
+2
-2
@@ -48,8 +48,8 @@ def parse_arguments():
|
||||
help_private_mode = 'Enable/Disable/Status private mode.'
|
||||
private_mode = subparsers.add_parser('private-mode',
|
||||
help=help_private_mode)
|
||||
private_mode.add_argument('command', choices=('enable', 'disable',
|
||||
'status'),
|
||||
private_mode.add_argument('command',
|
||||
choices=('enable', 'disable', 'status'),
|
||||
help=help_private_mode)
|
||||
|
||||
change_password = subparsers.add_parser('change-password',
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Configuration helper for Minetest server.
|
||||
"""
|
||||
@@ -25,7 +24,6 @@ import augeas
|
||||
|
||||
from plinth import action_utils
|
||||
|
||||
|
||||
CONFIG_FILE = '/etc/minetest/minetest.conf'
|
||||
AUG_PATH = '/files' + CONFIG_FILE + '/.anon'
|
||||
|
||||
|
||||
@@ -150,9 +150,8 @@ def get_monkeysphere_keys(key_id=None):
|
||||
"""Return the list of keys imported into monkeysphere."""
|
||||
try:
|
||||
key_ids = [] if not key_id else [key_id]
|
||||
output = subprocess.check_output(
|
||||
['monkeysphere-host', 'show-keys'] + key_ids,
|
||||
stderr=subprocess.DEVNULL)
|
||||
output = subprocess.check_output(['monkeysphere-host', 'show-keys'] +
|
||||
key_ids, stderr=subprocess.DEVNULL)
|
||||
except subprocess.CalledProcessError:
|
||||
# no keys available
|
||||
return {}
|
||||
@@ -288,9 +287,10 @@ def subcommand_host_publish_key(arguments):
|
||||
# setting TMPDIR as workaround for Debian bug #656750
|
||||
proc = subprocess.Popen(
|
||||
['monkeysphere-host', 'publish-keys'] + arguments.key_ids,
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=dict(
|
||||
os.environ, TMPDIR='/var/lib/monkeysphere/authentication/tmp/',
|
||||
MONKEYSPHERE_PROMPT='false'))
|
||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE,
|
||||
env=dict(os.environ,
|
||||
TMPDIR='/var/lib/monkeysphere/authentication/tmp/',
|
||||
MONKEYSPHERE_PROMPT='false'))
|
||||
output, error = proc.communicate()
|
||||
output, error = output.decode(), error.decode()
|
||||
if proc.returncode != 0:
|
||||
|
||||
+8
-8
@@ -177,8 +177,8 @@ def subcommand_upgrade(_):
|
||||
'renewed/private_by_serial', 'renewed/reqs_by_serial'
|
||||
]
|
||||
for dir_name in directories_to_create:
|
||||
os.makedirs(
|
||||
os.path.join(pki_dir, dir_name), mode=0o700, exist_ok=True)
|
||||
os.makedirs(os.path.join(pki_dir, dir_name), mode=0o700,
|
||||
exist_ok=True)
|
||||
|
||||
def _move_by_file_extension(file_extension, directory, excluded=None):
|
||||
excluded = excluded or []
|
||||
@@ -217,7 +217,6 @@ def _write_server_config():
|
||||
|
||||
def _setup_firewall():
|
||||
"""Add TUN device to internal zone in firewalld."""
|
||||
|
||||
def _configure_interface(interface, operation):
|
||||
"""Add or remove an interface into internal zone."""
|
||||
command = [
|
||||
@@ -299,9 +298,10 @@ def subcommand_get_profile(arguments):
|
||||
user_key_string = _read_file(user_key)
|
||||
ca_string = _read_file(CA_CERTIFICATE_PATH)
|
||||
|
||||
profile = CLIENT_CONFIGURATION.format(
|
||||
ca=ca_string, cert=user_certificate_string, key=user_key_string,
|
||||
remote=remote_server)
|
||||
profile = CLIENT_CONFIGURATION.format(ca=ca_string,
|
||||
cert=user_certificate_string,
|
||||
key=user_key_string,
|
||||
remote=remote_server)
|
||||
|
||||
print(profile)
|
||||
|
||||
@@ -326,8 +326,8 @@ def _is_non_empty_file(filepath):
|
||||
|
||||
def load_augeas():
|
||||
"""Initialize Augeas."""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
|
||||
# shell-script config file lens
|
||||
aug.set('/augeas/load/Simplevars/lens', 'Simplevars.lns')
|
||||
|
||||
+6
-4
@@ -349,8 +349,9 @@ def _download_packages(packages):
|
||||
return downloaded_files
|
||||
|
||||
|
||||
def _get_conffile_hashes_from_downloaded_files(
|
||||
packages, downloaded_files, status_hashes, mismatched_hashes):
|
||||
def _get_conffile_hashes_from_downloaded_files(packages, downloaded_files,
|
||||
status_hashes,
|
||||
mismatched_hashes):
|
||||
"""Retrieve the conffile hashes from downloaded .deb files."""
|
||||
new_hashes = defaultdict(dict)
|
||||
new_versions = defaultdict(lambda: None)
|
||||
@@ -369,8 +370,9 @@ def _get_conffile_hashes_from_downloaded_files(
|
||||
return new_hashes, new_versions
|
||||
|
||||
|
||||
def _get_conffile_hashes_from_downloaded_file(
|
||||
packages, downloaded_file, status_hashes, mismatched_hashes):
|
||||
def _get_conffile_hashes_from_downloaded_file(packages, downloaded_file,
|
||||
status_hashes,
|
||||
mismatched_hashes):
|
||||
"""Retrieve the conffile hashes from a single downloaded .deb file."""
|
||||
deb_file = apt_inst.DebFile(downloaded_file)
|
||||
|
||||
|
||||
+15
-10
@@ -31,13 +31,18 @@ from plinth.modules.pagekite import utils
|
||||
aug = None
|
||||
|
||||
PATHS = {
|
||||
'service_on': os.path.join(utils.CONF_PATH, '*', 'service_on', '*'),
|
||||
'kitename': os.path.join(utils.CONF_PATH, '10_account.rc', 'kitename'),
|
||||
'kitesecret': os.path.join(utils.CONF_PATH, '10_account.rc', 'kitesecret'),
|
||||
'abort_not_configured': os.path.join(utils.CONF_PATH, '10_account.rc',
|
||||
'abort_not_configured'),
|
||||
'defaults': os.path.join(utils.CONF_PATH, '20_frontends.rc', 'defaults'),
|
||||
'frontend': os.path.join(utils.CONF_PATH, '20_frontends.rc', 'frontend'),
|
||||
'service_on':
|
||||
os.path.join(utils.CONF_PATH, '*', 'service_on', '*'),
|
||||
'kitename':
|
||||
os.path.join(utils.CONF_PATH, '10_account.rc', 'kitename'),
|
||||
'kitesecret':
|
||||
os.path.join(utils.CONF_PATH, '10_account.rc', 'kitesecret'),
|
||||
'abort_not_configured':
|
||||
os.path.join(utils.CONF_PATH, '10_account.rc', 'abort_not_configured'),
|
||||
'defaults':
|
||||
os.path.join(utils.CONF_PATH, '20_frontends.rc', 'defaults'),
|
||||
'frontend':
|
||||
os.path.join(utils.CONF_PATH, '20_frontends.rc', 'frontend'),
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +55,9 @@ def parse_arguments():
|
||||
subparsers.add_parser('start-and-enable', help='Enable PageKite service')
|
||||
subparsers.add_parser('stop-and-disable', help='Disable PageKite service')
|
||||
subparsers.add_parser('restart', help='Restart PageKite service')
|
||||
subparsers.add_parser('is-disabled',
|
||||
help=('Whether PageKite is disabled in the file '
|
||||
'/etc/pagekite.d/10_accounts.rc'))
|
||||
subparsers.add_parser(
|
||||
'is-disabled', help=('Whether PageKite is disabled in the file '
|
||||
'/etc/pagekite.d/10_accounts.rc'))
|
||||
|
||||
# Frontend
|
||||
subparsers.add_parser('get-frontend', help='Get pagekite frontend')
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Configuration helper for power controls.
|
||||
"""
|
||||
|
||||
+2
-2
@@ -132,8 +132,8 @@ def subcommand_fix_collections(_):
|
||||
|
||||
def load_augeas():
|
||||
"""Initialize Augeas."""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
|
||||
# shell-script config file lens
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
|
||||
+2
-2
@@ -81,8 +81,8 @@ def _update_uwsgi_configuration():
|
||||
|
||||
uwsgi 2.0.15-debian crashes when trying to autoload.
|
||||
"""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/inifile/lens', 'Puppet.lns')
|
||||
aug.set('/augeas/load/inifile/incl[last() + 1]', UWSGI_FILE)
|
||||
aug.load()
|
||||
|
||||
+5
-6
@@ -35,12 +35,11 @@ def parse_arguments():
|
||||
parser = argparse.ArgumentParser()
|
||||
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
|
||||
|
||||
subparsers.add_parser('setup',
|
||||
help='Perform initial setup steps')
|
||||
subparsers.add_parser(
|
||||
'get-config', help='Read and print JSON config to stdout')
|
||||
subparsers.add_parser(
|
||||
'merge-config', help='Merge JSON config from stdin with existing')
|
||||
subparsers.add_parser('setup', help='Perform initial setup steps')
|
||||
subparsers.add_parser('get-config',
|
||||
help='Read and print JSON config to stdout')
|
||||
subparsers.add_parser('merge-config',
|
||||
help='Merge JSON config from stdin with existing')
|
||||
|
||||
subparsers.required = True
|
||||
return parser.parse_args()
|
||||
|
||||
+5
-4
@@ -58,8 +58,8 @@ def parse_arguments():
|
||||
|
||||
def load_augeas():
|
||||
"""Initialize augeas for this app's configuration file."""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Httpd/lens', 'Httpd.lns')
|
||||
aug.set('/augeas/load/Httpd/incl[last() + 1]', APACHE_CONFIGURATION)
|
||||
aug.load()
|
||||
@@ -191,8 +191,9 @@ def _list(aug=None):
|
||||
"""Must contain the line 'Require all granted'."""
|
||||
require = location + '//directive["Require"]'
|
||||
return bool(aug.match(require)) and aug.get(
|
||||
require + '/arg[1]') == 'all' and aug.get(
|
||||
require + '/arg[2]') == 'granted'
|
||||
require +
|
||||
'/arg[1]') == 'all' and aug.get(require +
|
||||
'/arg[2]') == 'granted'
|
||||
|
||||
for share in shares:
|
||||
if share['name'] == name:
|
||||
|
||||
+2
-2
@@ -117,8 +117,8 @@ def subcommand_set_keys(arguments):
|
||||
|
||||
def _load_augeas():
|
||||
"""Initialize augeas for this app's configuration file."""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Sshd/lens', 'Sshd.lns')
|
||||
aug.set('/augeas/load/Sshd/incl[last() + 1]', '/etc/ssh/sshd_config')
|
||||
aug.load()
|
||||
|
||||
+4
-4
@@ -96,11 +96,11 @@ def validate_mountpoint(mountpoint):
|
||||
"""Check that the folder is empty, and create it if it doesn't exist"""
|
||||
if os.path.exists(mountpoint):
|
||||
if _is_mounted(mountpoint):
|
||||
raise AlreadyMountedError(
|
||||
'Mountpoint %s already mounted' % mountpoint)
|
||||
raise AlreadyMountedError('Mountpoint %s already mounted' %
|
||||
mountpoint)
|
||||
if os.listdir(mountpoint) or not os.path.isdir(mountpoint):
|
||||
raise ValueError(
|
||||
'Mountpoint %s is not an empty directory' % mountpoint)
|
||||
raise ValueError('Mountpoint %s is not an empty directory' %
|
||||
mountpoint)
|
||||
else:
|
||||
os.makedirs(mountpoint)
|
||||
|
||||
|
||||
+5
-4
@@ -114,8 +114,8 @@ def subcommand_setup(arguments):
|
||||
def subcommand_autostart(_):
|
||||
"""Automatically start all introducers and storage nodes on system startup.
|
||||
"""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
aug.set('/augeas/load/Shellvars/incl[last() + 1]', DEFAULT_FILE)
|
||||
aug.load()
|
||||
@@ -157,8 +157,9 @@ def subcommand_create_storage_node(_):
|
||||
if not os.path.exists(os.path.join(tahoe_home, storage_node_name)):
|
||||
subprocess.check_call([
|
||||
'tahoe', 'create-node', '--nickname=\"storage_node\"',
|
||||
'--webport=1234', '--hostname={}'.format(
|
||||
get_configured_domain_name()), storage_node_name
|
||||
'--webport=1234',
|
||||
'--hostname={}'.format(get_configured_domain_name()),
|
||||
storage_node_name
|
||||
])
|
||||
with open(
|
||||
os.path.join(tahoe_home, introducer_name, 'private',
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
"""
|
||||
Set time zones with timedatectl (requires root permission).
|
||||
"""
|
||||
|
||||
+2
-2
@@ -529,8 +529,8 @@ def _update_ports():
|
||||
|
||||
def augeas_load():
|
||||
"""Initialize Augeas."""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Tor/lens', 'Tor.lns')
|
||||
aug.set('/augeas/load/Tor/incl[last() + 1]',
|
||||
'/etc/tor/instances/plinth/torrc')
|
||||
|
||||
+2
-2
@@ -133,8 +133,8 @@ def _run_as_postgres(command, stdin=None, stdout=None):
|
||||
|
||||
def load_augeas():
|
||||
"""Initialize Augeas."""
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
aug.set('/augeas/load/Shellvars/incl[last() + 1]', DEFAULT_FILE)
|
||||
aug.set('/augeas/load/Phpvars/lens', 'Phpvars.lns')
|
||||
|
||||
+2
-2
@@ -210,8 +210,8 @@ def configure_ldapscripts():
|
||||
# modify a copy of the config file
|
||||
shutil.copy('/etc/ldapscripts/ldapscripts.conf', LDAPSCRIPTS_CONF)
|
||||
|
||||
aug = augeas.Augeas(
|
||||
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
|
||||
augeas.Augeas.NO_MODL_AUTOLOAD)
|
||||
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
|
||||
aug.set('/augeas/load/Shellvars/incl[last() + 1]', LDAPSCRIPTS_CONF)
|
||||
aug.load()
|
||||
|
||||
Reference in new issue
Block a user