Univention Bugzilla – Attachment 10948 Details for
Bug 51996
Migration univention-appcenter-control script to Python 3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
patch (with argparse --required=True for subparsers)
univention-appcenter-control.patch (text/plain), 3.64 KB, created by
Florian Best
on 2022-05-09 21:28:08 CEST
(
hide
)
Description:
patch (with argparse --required=True for subparsers)
Filename:
MIME Type:
Creator:
Florian Best
Created:
2022-05-09 21:28:08 CEST
Size:
3.64 KB
patch
obsolete
>--- univention-appcenter-control.org 2022-05-09 20:54:37.652575680 +0200 >+++ univention-appcenter-control 2022-05-09 21:27:09.635572856 +0200 >@@ -1,4 +1,4 @@ >-#!/usr/bin/python2.7 >+#!/usr/bin/python3 > # -*- coding: utf-8 -*- > # > # Univention App Center >@@ -33,21 +33,16 @@ > # > > import json >-import re >+import logging > import os.path >-from subprocess import Popen, PIPE >-from argparse import SUPPRESS, Action >-from tempfile import NamedTemporaryFile >+import re >+import sys >+from argparse import SUPPRESS, Action, ArgumentParser, Namespace >+from contextlib import contextmanager > from distutils.version import LooseVersion >-from argparse import ArgumentParser, Namespace >-import logging > from getpass import getpass >-from contextlib import contextmanager >-import sys >- >- >-reload(sys) >-sys.setdefaultencoding('utf8') >+from subprocess import PIPE, Popen >+from tempfile import NamedTemporaryFile > > > PROGRAM = sys.argv[0] >@@ -96,6 +91,8 @@ > handler.setFormatter(formatter) > handler.addFilter(RangeFilter(min_level=logging.WARN)) > logger.addHandler(handler) >+ >+ > log_to_stream._already_set_up = False > > >@@ -121,8 +118,7 @@ > return new_cls > > >-class UniventionAppAction(object): >- __metaclass__ = UniventionAppActionMeta >+class UniventionAppAction(object, metaclass=UniventionAppActionMeta): > > parent_logger = get_base_logger().getChild('actions') > >@@ -186,7 +182,7 @@ > default = getattr(_namespace, action.dest) > args[action.dest] = default > args.update(kwargs) >- for key, value in args.iteritems(): >+ for key, value in args.items(): > setattr(namespace, key, value) > return namespace > >@@ -266,7 +262,7 @@ > return args.username > if not args.noninteractive: > try: >- username = raw_input('Username: ') >+ username = input('Username: ') > if not username: > raise EOFError() > except (EOFError, KeyboardInterrupt): >@@ -302,7 +298,7 @@ > if not password: > yield None > else: >- with NamedTemporaryFile('w+b') as password_file: >+ with NamedTemporaryFile('w+') as password_file: > password_file.write(password) > password_file.flush() > yield password_file.name >@@ -356,7 +352,7 @@ > server = 'https://%s' % server > uri = '%s/univention/%s' % (server, path) > args = [] >- for key, value in kwargs.iteritems(): >+ for key, value in kwargs.items(): > if value is None: > continue > if not isinstance(value, (tuple, list)): >@@ -385,6 +381,7 @@ > args = ['curl', '--cookie', self._cookiejar.name, '--cookie-jar', self._cookiejar.name, '-H', 'X-Requested-With: XmlHttpRequest', '-H', 'Accept: application/json; q=1'] + args + [uri] > process = Popen(args, stdout=PIPE, stderr=PIPE) > out, err = process.communicate() >+ out, err = out.decode('UTF-8'), err.decode('UTF-8') > try: > return json.loads(out) > except ValueError: >@@ -471,7 +468,6 @@ > ret.extend(app['versions']) > return ret > >- > def _find_app_versions(self, args): > ucs_version = self._get_ucs_version(args.app) > versions = self._find_all_app_versions(args) >@@ -685,7 +681,7 @@ > usage = PROGRAM > description = '%s is a program to use the Univention App Center Self Service' % PROGRAM > parser = ArgumentParser(usage=usage, description=description) >- subparsers = parser.add_subparsers(description='type %s <action> --help for further help and possible arguments' % PROGRAM, metavar='action') >+ subparsers = parser.add_subparsers(description='type %s <action> --help for further help and possible arguments' % PROGRAM, metavar='action', required=True) > > get_base_logger().setLevel(logging.DEBUG) > get_base_logger().addHandler(logging.NullHandler()) # this is to prevent warning messages >@@ -708,5 +704,6 @@ > ret = 0 > sys.exit(ret) > >+ > if __name__ == '__main__': > main()
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51996
:
10487
|
10947
| 10948 |
10949