This repository was archived by the owner on Aug 23, 2022. It is now read-only.
forked from Zaryob/inary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinary-cli
executable file
·115 lines (93 loc) · 3.17 KB
/
inary-cli
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/usr/bin/env python3
#
# Main fork Pisi: Copyright (C) 2005 - 2011, Tubitak/UEKAE
#
# Copyright (C) 2016 - 2018, Suleyman POYRAZ (AquilaNipalensis)
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# Please read the COPYING file.
#
import errno
import traceback
import signal
import os
import sys
import traceback
if os.path.exists("/usr/lib/sulin"):
sys.path.insert(0,"/usr/lib/sulin")
import inary
import inary.cli
import inary.context as ctx
import inary.db
from inary.errors import Error, ParserError
import inary.util
from inary.cli import inarycli
import gettext
gettext.bindtextdomain('inary', "/usr/share/locale")
gettext.textdomain('inary')
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
def sig_handler(sig, frame):
if sig == signal.SIGTERM:
exit()
def exit():
inary.util.noecho(False)
sys.exit(1)
def handle_exception(exception, value, tb):
signal.signal(signal.SIGINT, signal.SIG_IGN) # disable further interrupts
ui = inary.cli.CLI() # make a temporary UI
show_traceback = False
if isinstance(value, ParserError):
show_traceback = True
ui.error(_("\nUnhandled internal exception.\n"
"Please file a bug report to <https://github.com/SulinOS/inary/issues>."))
elif isinstance(value, Error):
ui.error(_("Program terminated."))
elif isinstance(value, KeyboardInterrupt):
ui.error(_("\nKeyboard Interrupt [Ctrl-C]: Exiting..."))
exit()
elif isinstance(value, EOFError):
ui.error(_("\nKeyboard Interrupt [Ctrl-D]: Exiting..."))
exit()
elif isinstance(value, IOError) and value.errno == errno.EPIPE:
# Ignore broken pipe errors
sys.exit(0)
else:
# For any other exception (possibly Python exceptions) show
# the traceback!
show_traceback = ctx.get_option('debug')
ui.error(_("System error. Program terminated."))
if show_traceback:
ui.error("{}: {}".format(exception, str(value)))
else:
msg = str(value)
if msg:
ui.error(msg)
ui.info(_("Please use 'inary help' for general help."))
if show_traceback:
ui.info(_("\nTraceback:"))
traceback.print_tb(tb)
elif not isinstance(value, inary.errors.Error):
ui.info(_("Use --debug to see a traceback."))
exit()
# This is blocking WSL bash to supply stability of packages
# created by packagers.
def blc_wsl():
"""Dont allow fucking WSL"""
f = str(os.uname()).lower()
if (("microsoft" in f) or ("wsl" in f) or inary.util.get_cpuinfo("microcode") == "0xffffffff"):
ui = inary.cli.CLI()
ui.error(_("Using inary in WSL environment is not allowed."))
exit(1)
if __name__ == "__main__":
blc_wsl()
sys.excepthook = handle_exception
signal.signal(signal.SIGTERM, sig_handler)
cli = inary.cli.inarycli.InaryCLI()
if cli.command.name[1] in "rdb sf".split():
ctx.filesdb = inary.db.filesdb.FilesDB()
cli.run_command()