commit 8ff898bba4fd645e9345f50b681bb520630c2aa6
Author: Ville Skyttä <ville.skytta(a)iki.fi>
Date: Sat Dec 5 20:04:31 2015 +0200
Python 3 compatibility fixes
pkgdb2client/__init__.py | 12 +++++-------
pkgdb2client/admin.py | 6 ++++--
setup.py | 2 +-
test.py | 3 ++-
4 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/pkgdb2client/__init__.py b/pkgdb2client/__init__.py
index d21b654..6dc374d 100644
--- a/pkgdb2client/__init__.py
+++ b/pkgdb2client/__init__.py
@@ -15,15 +15,13 @@
# license.
"""
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
import getpass
import logging
import os
import pkg_resources
+from six.moves import input, cPickle as pickle, xrange
+
import fedora_cert
from fedora.client import AuthError
import requests
@@ -95,7 +93,7 @@ def ask_password(username=None, bad_password=False):
username = fedora_cert.read_user_cert()
except fedora_cert.fedora_cert_error:
LOG.debug('Could not read Fedora cert, asking for username')
- username = raw_input("Username: ")
+ username = input("Username: ")
password = getpass.getpass("FAS password for user {0}: ".format(username))
return username, password
@@ -176,7 +174,7 @@ class PkgDB(object):
except:
data = {}
try:
- with open(self.sessionfile, 'wb', 0600) as sessionfo:
+ with open(self.sessionfile, 'wb', 0o600) as sessionfo:
sessionfo.seek(0)
data["cookies"] = self.session.cookies
pickle.dump(data, sessionfo)
@@ -218,7 +216,7 @@ class PkgDB(object):
raise PkgDBAuthException('Username or password missing')
import re
- from urlparse import urlparse, parse_qs
+ from six.moves.urllib.parse import urlparse, parse_qs
fedora_openid_api =
r'https://id.fedoraproject.org/api/v1/'
fedora_openid = r'^http(s)?:\/\/id\.(|stg.|dev.)?fedoraproject'\
diff --git a/pkgdb2client/admin.py b/pkgdb2client/admin.py
index 8f0673d..086d159 100644
--- a/pkgdb2client/admin.py
+++ b/pkgdb2client/admin.py
@@ -20,6 +20,8 @@ from fedora.client import (AppError, ServerError)
import argparse
import logging
+from six.moves import input
+
from pkgdb2client import PkgDB, PkgDBException, __version__
from pkgdb2client.cli import ActionError
import pkgdb2client
@@ -257,7 +259,7 @@ def _ask_what_to_do(messages):
print("==> " + "All checks were good")
print('\nWhat should we do about this requests?')
- action = raw_input('approve, deny, pass: ')
+ action = input('approve, deny, pass: ')
if action.lower() not in ['a', 'd', 'p', 'approve',
'deny', 'pass']:
print('No valid action specified, just ignoring for now')
action = 'pass'
@@ -312,7 +314,7 @@ def __handle_request_package(actionid, action):
)
elif decision in ('deny', 'd'):
- message = raw_input(
+ message = input(
'Could you explain why you declined this request? (this message '
'will be sent to the user)\n=>')
data = PKGDBCLIENT.handle_api_call(
diff --git a/setup.py b/setup.py
index cabfe5c..156bcf1 100644
--- a/setup.py
+++ b/setup.py
@@ -22,7 +22,7 @@ setup(
]
},
install_requires=[
- 'requests', 'python-bugzilla', 'python-fedora',
'setuptools',
+ 'requests', 'python-bugzilla', 'python-fedora',
'setuptools', 'six',
'beautifulsoup4'],
classifiers=[
'Development Status :: 5 - Production/Stable',
diff --git a/test.py b/test.py
index 9024664..9bb86b1 100644
--- a/test.py
+++ b/test.py
@@ -7,6 +7,7 @@ import unittest
import uuid
from functools import wraps
+from six.moves import input
import fedora_cert
@@ -20,7 +21,7 @@ if AUTH:
try:
USERNAME = fedora_cert.read_user_cert()
except:
- USERNAME = raw_input('FAS username: ')
+ USERNAME = input('FAS username: ')
PASSWORD = getpass.getpass('FAS password: ')
if not PASSWORD:
AUTH = False