Skip to content
This repository has been archived by the owner on Nov 19, 2021. It is now read-only.

Version 1.4.x #131

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pnc_cli/makemead.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import os
import re
import sys
from ConfigParser import Error
from ConfigParser import NoSectionError
from configparser import Error
from configparser import NoSectionError

from argh import arg

Expand Down Expand Up @@ -53,7 +53,7 @@ def make_mead_impl(config, run_build, environment, sufix, product_name, product_
except NoSectionError as e:
logging.error('Missing config in %s (%r)', config, e)
return 1
except Error, err:
except Error as err:
logging.error(err)
return 1

Expand Down
2 changes: 0 additions & 2 deletions pnc_cli/repositoryconfigurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
from argh.exceptions import CommandError

import logging
import pnc_cli.common as common
import pnc_cli.cli_types as types
from pnc_cli import swagger_client
from pnc_cli import utils
from pnc_cli.pnc_api import pnc_api

Expand Down
2 changes: 1 addition & 1 deletion pnc_cli/runningbuilds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from pnc_cli import utils
from pnc_cli.pnc_api import pnc_api

import cli_types
from pnc_cli import cli_types


@arg("-p", "--page-size", help="Limit the amount of BuildRecords returned")
Expand Down
9 changes: 5 additions & 4 deletions pnc_cli/swagger_client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,20 @@
import re
import json
import mimetypes
import random
import sys
import tempfile
import threading

from datetime import date, datetime

# python 2 and python 3 compatibility library
from six import PY3, integer_types, iteritems, text_type
from six import integer_types, iteritems, text_type
from six.moves.urllib.parse import quote

from . import models
from .configuration import Configuration
from .rest import ApiException, RESTClientObject

from builtins import str as text

class ApiClient(object):
"""
Expand All @@ -46,6 +46,7 @@ class ApiClient(object):
:param header_name: a header to pass when making calls to the API.
:param header_value: a header value to pass when making calls to the API.
"""
PY3 = sys.version_info[0] >= 3;

PRIMITIVE_TYPES = (float, bool, bytes, text_type) + integer_types
NATIVE_TYPES_MAPPING = {
Expand Down Expand Up @@ -556,7 +557,7 @@ def __deserialize_primitive(self, data, klass):
try:
return klass(data)
except UnicodeEncodeError:
return unicode(data)
return text(data)
except TypeError:
return data

Expand Down
1 change: 1 addition & 0 deletions pnc_cli/swagger_client/rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from six.moves.urllib.parse import urlencode

from .configuration import Configuration
from past.builtins import long

try:
import urllib3
Expand Down
22 changes: 11 additions & 11 deletions pnc_cli/tools/config_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
import os
import re
import string
from ConfigParser import ConfigParser, NoOptionError, NoSectionError, DuplicateSectionError
from configparser import ConfigParser, NoOptionError, NoSectionError, DuplicateSectionError

import utils
from scm_utils import ScmInfo, get_scm_info
from tasks import Tasks
# import utils
# from scm_utils import ScmInfo, get_scm_info
# from tasks import Tasks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't comment out code, either keep it or remove it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! We're actually using all those imports. It should be commented out

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right. mistake. when you will remove the comment, you must change the import to conform to python 2 and python 3 rules at the same time (ATM it works only in python 2 but not in 3) - eg. "import utils" -> "from . import utils"



def get_config_option(params, option):
Expand Down Expand Up @@ -159,7 +159,7 @@ def get_dependency_structure(self, artifact=None, include_dependencies=False):
artifacts = []
dependencies_dict = {}
if artifact:
if isinstance(artifact, basestring):
if isinstance(artifact, str):
artifact = self.get_tasks().get_task(artifact)
artifacts.append(artifact.name)
dependencies_dict[artifact.name] = artifact.ordered_dependencies()
Expand Down Expand Up @@ -381,7 +381,7 @@ def _do_read_config(self, config_file, pommanipext):

if not parser.has_section('common'):
logging.error('Mandatory common section missing from configuration file.')
raise NoSectionError, 'Mandatory common section missing from configuration file.'
raise NoSectionError('Mandatory common section missing from configuration file.')
common_section['tag'] = parser.get('common', 'tag')
common_section['target'] = parser.get('common', 'target')
common_section['jobprefix'] = parser.get('common', 'jobprefix')
Expand Down Expand Up @@ -497,7 +497,7 @@ def config_has_option(parser, pommanipext, option, warn=True):
def parse_pom_manipulator_ext(params, parser, pommanipext):
if not parser.has_section(pommanipext):
logging.error('Unable to locate dependency-management-section "{0}".'.format(pommanipext))
raise NoSectionError, 'Unable to locate dependency-management-section "{0}".'.format(pommanipext)
raise NoSectionError ('Unable to locate dependency-management-section "{0}".'.format(pommanipext))

if config_has_option(parser, pommanipext, 'depmgmt'):
params['dependencyManagement'] = read_value_add_version_if_not_present(parser, pommanipext, 'depmgmt')
Expand Down Expand Up @@ -631,10 +631,10 @@ def __init__(self, message):
super(ConfigException, self).__init__(message)


from ConfigParser import InterpolationMissingOptionError
from ConfigParser import InterpolationSyntaxError, InterpolationDepthError
from ConfigParser import MAX_INTERPOLATION_DEPTH
from ConfigParser import DEFAULTSECT
from configparser import InterpolationMissingOptionError
from configparser import InterpolationSyntaxError, InterpolationDepthError
from configparser import MAX_INTERPOLATION_DEPTH
from configparser import DEFAULTSECT
_UNSET = object()

class InterpolationConfigParser(ConfigParser):
Expand Down
14 changes: 10 additions & 4 deletions pnc_cli/tools/maven_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,14 @@
import os
import shutil
import string
import urllib2
import urlparse

from future.standard_library import install_aliases
install_aliases()

from urllib.parse import urlparse, urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTPError

from subprocess import Popen
from subprocess import PIPE
from subprocess import STDOUT
Expand Down Expand Up @@ -240,8 +246,8 @@ def download_pom(repo_url=None, artifact=None, pom_url=None, target_dir=None):

handler = None
try:
handler = urllib2.urlopen(pom_url)
except urllib2.HTTPError, err:
handler = urlopen(pom_url)
except HTTPError as err:
logging.error("Failed to download POM %s. %s", pom_url, err)
return None

Expand Down
6 changes: 3 additions & 3 deletions pnc_cli/tools/scm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
from subprocess import Popen
from subprocess import STDOUT

import maven_utils
import web_utils
from maven_utils import MavenArtifact
from . import maven_utils
from . import web_utils
from pnc_cli.tools.maven_utils import MavenArtifact

git_version = None

Expand Down
4 changes: 2 additions & 2 deletions pnc_cli/tools/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def tsort(self):
result.append(level)
parts = dict([(name, deps - level) for name, deps in parts.iteritems() if name not in level])
if parts:
raise ValueError, 'total ordering not possible (check for circular or missing dependencies)'
raise ValueError('total ordering not possible (check for circular or missing dependencies)')
return result

def get_all(self):
Expand Down Expand Up @@ -291,7 +291,7 @@ def process_job(self, semaphore, process_finished_notify, task_conn, config_conn
try:
exit_status = self.run_build(task, build_config)
except Exception:
print traceback.format_exc()
print(traceback.format_exc())
exit_status = 1

if exit_status != 0:
Expand Down
28 changes: 19 additions & 9 deletions pnc_cli/tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,27 @@
import sys
import getpass

import exceptions
from future.standard_library import install_aliases
install_aliases()

from urllib.parse import urlparse, urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTPError

try:
input = raw_input
except NameError:
pass


def execute_command(cmd, execute, echo=True):
"""Execute a command in shell or just print it if execute is False"""
if execute:
if echo:
print "Executing: " + cmd
print("Executing: " + cmd)
return os.system(cmd)
else:
print cmd
print(cmd)
return 0

def set_log_level(level):
Expand Down Expand Up @@ -103,19 +113,19 @@ def parse_conf_args(argv):

fsplit = arg.split('=', 1)
if len(fsplit) != 2:
raise exceptions.InvalidOptionError(
raise Exception(
"Command option '%s' not recognized." % rarg)

rkey, value = fsplit
ssplit = rkey.split('.', 1)
if len(ssplit) != 2 or not ssplit[1]:
raise exceptions.InvalidOptionError(
raise Exception(
"Command option '%s' not recognized." % rarg)

section, option = ssplit
args[section] = (option, value)
else:
raise exceptions.InvalidOptionError(
raise Exception(
"Command option '%s' not recognized." % rarg)

return args
Expand All @@ -125,8 +135,8 @@ def get_user_creds():

:return: Pair of username (first) and password (second).
"""
print "Please provide your JIRA credentials"
username = raw_input("Username: ")
print("Please provide your JIRA credentials")
username = input("Username: ")
password = getpass.getpass()

return (username, password)
Expand All @@ -139,7 +149,7 @@ def wrap(f):
def wrappedf(*args):
result = f(*args)
if result is None or result == "":
raise exceptions.InvalidConfigError(
raise Exception(
"Config option '%s' is required." % field)
else:
return result
Expand Down
11 changes: 8 additions & 3 deletions pnc_cli/tools/web_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,19 @@

import logging
import os
import urllib2

from future.standard_library import install_aliases
install_aliases()

from urllib.parse import urlparse, urlencode
from urllib.request import urlopen, Request
from urllib.error import HTTPError

def download_file(file_url, file_path, artifact):
try:
logging.debug("Downloading from %s to '%s'", file_url, file_path)
handler = urllib2.urlopen(file_url)
except urllib2.HTTPError, err:
handler = urlopen(file_url)
except HTTPError as err:
logging.error("[%s] Failed to download %s. %s", artifact, file_url, err)
return None
if handler.getcode() == 200:
Expand Down
10 changes: 5 additions & 5 deletions pnc_cli/user_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

import requests

import swagger_client
from . import swagger_client
import pnc_cli.utils as utils
import keycloak_config as kc
import pnc_server_config as psc
from . import keycloak_config as kc
from . import pnc_server_config as psc

# make sure that input behaves as expected
try:
Expand Down Expand Up @@ -133,7 +133,7 @@ def load_username_from_config(self, config):
except (NoSectionError, NoOptionError):
logging.info("Username not specified in section PNC of %s" % self.configFileName)
return None
except Exception, e:
except Exception as e:
logging.error('Error reading username from section PNC of %s - %s' % (self.configFileName, str(e)))
return None

Expand All @@ -145,7 +145,7 @@ def load_password_from_config(self, config):
except (NoSectionError, NoOptionError):
logging.info("Password not specified in section PNC of %s" % self.configFileName)
return None
except Exception, e:
except Exception as e:
logging.error('Error reading password from section PNC of %s - %s' % (self.configFileName, str(e)))
return None

Expand Down
7 changes: 4 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@
keywords = ['PNC','REST'],
long_description=README,
install_requires=[
"argh >= 0.26.1",
"argh >= 0.26.1",
"requests >= 2.4.3",
"certifi >= 2015.04.28",
"urllib3 >= 1.12",
"six >= 1.9.0",
"urllib3 >= 1.12",
"six >= 1.9.0",
"validators >=0.10",
"tzlocal >= 1.0",
"future >= 0.17.1",
],
tests_require=["pytest >= 2.0"],
classifiers=[
Expand Down