#2 Make the clone command work
Merged 7 months ago by lrossett. Opened 7 months ago by zlopez.
centos/ zlopez/centpkg clone  into  develop

Clone command is working
Michal Konečný • 7 months ago  
Add --config argument
Michal Konečný • 7 months ago  
Add requirements file
Michal Konečný • 7 months ago  
file modified
+2

@@ -4,3 +4,5 @@ 

  *.pyc

  .ropeproject

  .pytest_cache

+ test.conf

+ .venv/

file modified
+4

@@ -10,6 +10,10 @@ 

  Exception handling at the top level has been disabled for now to get better

  tracebacks during development. 

  

+ ## Supported commands

+ Here is the list currently supported commands by centpkg:

+ * clone

+ 

  ## Current workflow

  For a sig working on a package in git.centos.org, the following workflow is

  recommended:

file added
+2

@@ -0,0 +1,2 @@ 

+ rpkg

+ rpm

file modified
+31

@@ -1,5 +1,35 @@ 

  from setuptools import setup

  

+ def get_requirements(requirements_file="requirements.txt"):

+     """Get the contents of a file listing the requirements.

+ 

+     :arg requirements_file: path to a requirements file

+     :type requirements_file: string

+     :returns: the list of requirements, or an empty list if

+               `requirements_file` could not be opened or read

+     :return type: list

+     """

+ 

+     lines = open(requirements_file).readlines()

+     dependencies = []

+     for line in lines:

+         maybe_dep = line.strip()

+         if maybe_dep.startswith("#"):

+             # Skip pure comment lines

+             continue

+         if maybe_dep.startswith("git+"):

+             # VCS reference for dev purposes, expect a trailing comment

+             # with the normal requirement

+             __, __, maybe_dep = maybe_dep.rpartition("#")

+         else:

+             # Ignore any trailing comment

+             maybe_dep, __, __ = maybe_dep.partition("#")

+         # Remove any whitespace and assume non-empty results are dependencies

+         maybe_dep = maybe_dep.strip()

+         if maybe_dep:

+             dependencies.append(maybe_dep)

+     return dependencies

+ 

  setup(

      name="centpkg",

      version='0.4.6',

@@ -9,6 +39,7 @@ 

      license="GPLv2+",

      package_dir={'': 'src'},

      packages=['centpkg'],

+     install_requires=get_requirements(),

      scripts=['src/bin/centpkg'],

      data_files=[('/etc/rpkg',['src/centpkg.conf']),]

  )

file modified
+2 -2

@@ -4,8 +4,8 @@ 

  lookaside_cgi = https://sources.stream.rdu2.redhat.com/lookaside/upload.cgi

  distgit_namespaced = True

  distgit_namespaces = rpms

- gitbaseurl = ssh://git@gitlab.com/%(repo)s.git

- anongiturl = https://gitlab.com/%(repo)s

+ gitbaseurl = ssh://git@gitlab.com/redhat/centos-stream/%(repo)s.git

+ anongiturl = https://gitlab.com/redhat/centos-stream/%(repo)s

  branchre = .+\d$|.+\d-.+|master$

  kojiprofile = stream-koji

  build_client = stream-koji

file modified
+7 -4

@@ -35,13 +35,16 @@ 

      parser.add_argument('-S', '--sig', help='Operate as a CentOS SIG user instead of using the Stream distro environment',

                          default=False,

                          action='store_true')

+     parser.add_argument('-C', '--config', help='Specify a config file to use')

Does it make sense to add the "default" value in here?

+ 

  

      (args, other) = parser.parse_known_args()

  

-     if args.sig:

-         args.config = '/etc/rpkg/centpkg-sig.conf'

-     else:

-         args.config = '/etc/rpkg/centpkg.conf'

+     if not args.config:

+         if args.sig:

+             args.config = '/etc/rpkg/centpkg-sig.conf'

+         else:

+             args.config = '/etc/rpkg/centpkg.conf'

  

      # Make sure we have a sane config file

      if not os.path.exists(args.config) and not other[-1] in ['--help', '-h', 'help']:

The centpkg will now work with clone command.

Does it make sense to add the "default" value in here?

No, because the default will be different for centpkg and centpkg-sig

But it could make sense if we add different parse arguments for each executable and then add default to each of them

You could add custom action for that arg as described here: https://docs.python.org/3/library/argparse.html#action - but I think that would be a bit of over engineering.

I think the default will be fine, just we need to do different defaults for centpkg and centpkg-sig

I tried your PR but I keep getting this error: AttributeError: module 'centpkg.cli' has no attribute 'centpkgClient

This is really strange, how did you tested it?

I just ran python setup.py install and tried to run the centpkg command.

Also using virtual env.

NVM, my folder was messed up.. it worked now.

LGTM - clone subcommand worked.

Pull-Request has been merged by lrossett

7 months ago