Python 3 port:
/!\ this is a huge commit /!\ starting from this commit, SàT is needs Python 3.6+ /!\ SàT maybe be instable or some feature may not work anymore, this will improve with time This patch port backend, bridge and frontends to Python 3. Roughly this has been done this way: - 2to3 tools has been applied (with python 3.7) - all references to python2 have been replaced with python3 (notably shebangs) - fixed files not handled by 2to3 (notably the shell script) - several manual fixes - fixed issues reported by Python 3 that where not handled in Python 2 - replaced "async" with "async_" when needed (it's a reserved word from Python 3.7) - replaced zope's "implements" with @implementer decorator - temporary hack to handle data pickled in database, as str or bytes may be returned, to be checked later - fixed hash comparison for password - removed some code which is not needed anymore with Python 3 - deactivated some code which needs to be checked (notably certificate validation) - tested with jp, fixed reported issues until some basic commands worked - ported Primitivus (after porting dependencies like urwid satext) - more manual fixes
This commit is contained in:
parent
d21a6a660f
commit
fbfe96c505
1 changed files with 6336 additions and 6398 deletions
|
|
@ -18,7 +18,7 @@
|
|||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import base
|
||||
from . import base
|
||||
from sat.core.i18n import _
|
||||
from sat.tools.common import data_format
|
||||
from sat_frontends.jp.constants import Const as C
|
||||
|
|
@ -37,8 +37,8 @@ class Set(base.CommandBase):
|
|||
host,
|
||||
"set",
|
||||
use_pubsub=True,
|
||||
pubsub_defaults={u"service": _(u"auto"), u"node": _(u"auto")},
|
||||
help=_(u"publish or update a merge request"),
|
||||
pubsub_defaults={"service": _("auto"), "node": _("auto")},
|
||||
help=_("publish or update a merge request"),
|
||||
)
|
||||
self.need_loop = True
|
||||
|
||||
|
|
@ -46,59 +46,56 @@ class Set(base.CommandBase):
|
|||
self.parser.add_argument(
|
||||
"-i",
|
||||
"--item",
|
||||
type=base.unicode_decoder,
|
||||
default=u"",
|
||||
help=_(u"id or URL of the request to update, or nothing for a new one"),
|
||||
default="",
|
||||
help=_("id or URL of the request to update, or nothing for a new one"),
|
||||
)
|
||||
self.parser.add_argument(
|
||||
"-r",
|
||||
"--repository",
|
||||
metavar="PATH",
|
||||
type=base.unicode_decoder,
|
||||
default=u".",
|
||||
help=_(u"path of the repository (DEFAULT: current directory)"),
|
||||
default=".",
|
||||
help=_("path of the repository (DEFAULT: current directory)"),
|
||||
)
|
||||
self.parser.add_argument(
|
||||
"-f",
|
||||
"--force",
|
||||
action="store_true",
|
||||
help=_(u"publish merge request without confirmation"),
|
||||
help=_("publish merge request without confirmation"),
|
||||
)
|
||||
self.parser.add_argument(
|
||||
"-l",
|
||||
"--label",
|
||||
dest="labels",
|
||||
type=base.unicode_decoder,
|
||||
action="append",
|
||||
help=_(u"labels to categorize your request"),
|
||||
help=_("labels to categorize your request"),
|
||||
)
|
||||
|
||||
def mergeRequestSetCb(self, published_id):
|
||||
if published_id:
|
||||
self.disp(u"Merge request published at {pub_id}".format(pub_id=published_id))
|
||||
self.disp("Merge request published at {pub_id}".format(pub_id=published_id))
|
||||
else:
|
||||
self.disp(u"Merge request published")
|
||||
self.disp("Merge request published")
|
||||
self.host.quit(C.EXIT_OK)
|
||||
|
||||
def sendRequest(self):
|
||||
extra = {"update": True} if self.args.item else {}
|
||||
values = {}
|
||||
if self.args.labels is not None:
|
||||
values[u"labels"] = self.args.labels
|
||||
values["labels"] = self.args.labels
|
||||
self.host.bridge.mergeRequestSet(
|
||||
self.args.service,
|
||||
self.args.node,
|
||||
self.repository,
|
||||
u"auto",
|
||||
"auto",
|
||||
values,
|
||||
u"",
|
||||
"",
|
||||
self.args.item,
|
||||
data_format.serialise(extra),
|
||||
self.profile,
|
||||
callback=self.mergeRequestSetCb,
|
||||
errback=partial(
|
||||
self.errback,
|
||||
msg=_(u"can't create merge request: {}"),
|
||||
msg=_("can't create merge request: {}"),
|
||||
exit_code=C.EXIT_BRIDGE_ERRBACK,
|
||||
),
|
||||
)
|
||||
|
|
@ -106,9 +103,9 @@ class Set(base.CommandBase):
|
|||
def askConfirmation(self):
|
||||
if not self.args.force:
|
||||
message = _(
|
||||
u"You are going to publish your changes to service [{service}], are you sure ?"
|
||||
"You are going to publish your changes to service [{service}], are you sure ?"
|
||||
).format(service=self.args.service)
|
||||
self.host.confirmOrQuit(message, _(u"merge request publication cancelled"))
|
||||
self.host.confirmOrQuit(message, _("merge request publication cancelled"))
|
||||
self.sendRequest()
|
||||
|
||||
def start(self):
|
||||
|
|
@ -125,8 +122,8 @@ class Get(base.CommandBase):
|
|||
use_verbose=True,
|
||||
use_pubsub=True,
|
||||
pubsub_flags={C.MULTI_ITEMS},
|
||||
pubsub_defaults={u"service": _(u"auto"), u"node": _(u"auto")},
|
||||
help=_(u"get a merge request"),
|
||||
pubsub_defaults={"service": _("auto"), "node": _("auto")},
|
||||
help=_("get a merge request"),
|
||||
)
|
||||
self.need_loop = True
|
||||
|
||||
|
|
@ -141,7 +138,7 @@ class Get(base.CommandBase):
|
|||
for request_xmlui in requests_data[0]:
|
||||
xmlui = xmlui_manager.create(self.host, request_xmlui, whitelist=whitelist)
|
||||
xmlui.show(values_only=True)
|
||||
self.disp(u"")
|
||||
self.disp("")
|
||||
self.host.quit(C.EXIT_OK)
|
||||
|
||||
def getRequests(self):
|
||||
|
|
@ -151,13 +148,13 @@ class Get(base.CommandBase):
|
|||
self.args.node,
|
||||
self.args.max,
|
||||
self.args.items,
|
||||
u"",
|
||||
"",
|
||||
extra,
|
||||
self.profile,
|
||||
callback=self.mergeRequestGetCb,
|
||||
errback=partial(
|
||||
self.errback,
|
||||
msg=_(u"can't get merge request: {}"),
|
||||
msg=_("can't get merge request: {}"),
|
||||
exit_code=C.EXIT_BRIDGE_ERRBACK,
|
||||
),
|
||||
)
|
||||
|
|
@ -176,8 +173,8 @@ class Import(base.CommandBase):
|
|||
"import",
|
||||
use_pubsub=True,
|
||||
pubsub_flags={C.SINGLE_ITEM, C.ITEM},
|
||||
pubsub_defaults={u"service": _(u"auto"), u"node": _(u"auto")},
|
||||
help=_(u"import a merge request"),
|
||||
pubsub_defaults={"service": _("auto"), "node": _("auto")},
|
||||
help=_("import a merge request"),
|
||||
)
|
||||
self.need_loop = True
|
||||
|
||||
|
|
@ -186,9 +183,8 @@ class Import(base.CommandBase):
|
|||
"-r",
|
||||
"--repository",
|
||||
metavar="PATH",
|
||||
type=base.unicode_decoder,
|
||||
default=u".",
|
||||
help=_(u"path of the repository (DEFAULT: current directory)"),
|
||||
default=".",
|
||||
help=_("path of the repository (DEFAULT: current directory)"),
|
||||
)
|
||||
|
||||
def mergeRequestImportCb(self):
|
||||
|
|
@ -206,7 +202,7 @@ class Import(base.CommandBase):
|
|||
callback=self.mergeRequestImportCb,
|
||||
errback=partial(
|
||||
self.errback,
|
||||
msg=_(u"can't import merge request: {}"),
|
||||
msg=_("can't import merge request: {}"),
|
||||
exit_code=C.EXIT_BRIDGE_ERRBACK,
|
||||
),
|
||||
)
|
||||
|
|
|
|||
Loading…
Reference in a new issue