core: run ruff format

This commit is contained in:
RhodeCode Admin 2025-01-13 17:47:37 +01:00
parent 7130effb58
commit 166db21812
821 changed files with 82905 additions and 84121 deletions

View file

@ -32,41 +32,45 @@ log = logging.getLogger(__name__)
@click.command()
@click.argument('ini_path', type=click.Path(exists=True))
@click.argument("ini_path", type=click.Path(exists=True))
@click.option(
'--mode', '-m', required=False, default='auto',
type=click.Choice(['auto', 'vcs', 'git', 'hg', 'svn', 'test']),
help='mode of operation')
@click.option('--user', help='Username for which the command will be executed')
@click.option('--user-id', help='User ID for which the command will be executed')
@click.option('--key-id', help='ID of the key from the database')
@click.option('--shell', '-s', is_flag=True, help='Allow Shell')
@click.option('--debug', is_flag=True, help='Enabled detailed output logging')
"--mode",
"-m",
required=False,
default="auto",
type=click.Choice(["auto", "vcs", "git", "hg", "svn", "test"]),
help="mode of operation",
)
@click.option("--user", help="Username for which the command will be executed")
@click.option("--user-id", help="User ID for which the command will be executed")
@click.option("--key-id", help="ID of the key from the database")
@click.option("--shell", "-s", is_flag=True, help="Allow Shell")
@click.option("--debug", is_flag=True, help="Enabled detailed output logging")
def main(ini_path, mode, user, user_id, key_id, shell, debug):
setup_custom_logging(ini_path, debug)
command = os.environ.get('SSH_ORIGINAL_COMMAND', '')
if not command and mode not in ['test']:
command = os.environ.get("SSH_ORIGINAL_COMMAND", "")
if not command and mode not in ["test"]:
raise ValueError(
'Unable to fetch SSH_ORIGINAL_COMMAND from environment.'
'Please make sure this is set and available during execution '
'of this script.')
connection_info = os.environ.get('SSH_CONNECTION', '')
"Unable to fetch SSH_ORIGINAL_COMMAND from environment."
"Please make sure this is set and available during execution "
"of this script."
)
connection_info = os.environ.get("SSH_CONNECTION", "")
time_start = time.time()
with bootstrap(ini_path, env={'RC_CMD_SSH_WRAPPER': '1'}) as env:
settings = env['registry'].settings
with bootstrap(ini_path, env={"RC_CMD_SSH_WRAPPER": "1"}) as env:
settings = env["registry"].settings
statsd = StatsdClient.statsd
try:
ssh_wrapper = SshWrapper(
command, connection_info, mode,
user, user_id, key_id, shell, ini_path, settings, env)
command, connection_info, mode, user, user_id, key_id, shell, ini_path, settings, env
)
except Exception:
log.exception('Failed to execute SshWrapper')
log.exception("Failed to execute SshWrapper")
sys.exit(-5)
return_code = ssh_wrapper.wrap()
operation_took = time.time() - time_start
if statsd:
operation_took_ms = round(1000.0 * operation_took)
statsd.timing("rhodecode_ssh_wrapper_timing.histogram", operation_took_ms,
use_decimals=False)
statsd.timing("rhodecode_ssh_wrapper_timing.histogram", operation_took_ms, use_decimals=False)
sys.exit(return_code)