#1312 cleanup: refactor scripts via entry points
Merged 4 years ago by lsedlar. Opened 4 years ago by hlin.
hlin/pungi entry-points  into  master

file removed
-15
@@ -1,15 +0,0 @@ 

- #!/usr/bin/env python

- # -*- coding: utf-8 -*-

- 

- import os

- import sys

- 

- here = sys.path[0]

- if here != '/usr/bin':

-     sys.path.insert(0, os.path.dirname(here))

- 

- from pungi import ostree

- 

- 

- if __name__ == '__main__':

-     ostree.main()

file removed
-16
@@ -1,16 +0,0 @@ 

- #!/usr/bin/env python

- # -*- coding: utf-8 -*-

- 

- import os

- import sys

- 

- here = sys.path[0]

- if here != '/usr/bin':

-     # Git checkout

-     sys.path[0] = os.path.dirname(here)

- 

- from pungi_utils import orchestrator

- 

- 

- if __name__ == '__main__':

-     orchestrator.main()

file modified
+1
@@ -158,6 +158,7 @@ 

  you can use to try and create a miniature compose on dummy data. The actual

  data will be created by running ``make test-data`` in project root. ::

  

+     $ python setup.py develop

      $ make test-data

      $ make test-compose

  

empty or binary file added
file renamed
+1 -5
@@ -1,6 +1,6 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

+ from __future__ import absolute_import

  

  import sys

  import argparse
@@ -68,7 +68,3 @@ 

          f.remove_environments()

  

      f.write(open(opts.output, 'wb') if opts.output else sys.stdout)

- 

- 

- if __name__ == "__main__":

-     main()

pungi/scripts/config_dump.py bin/pungi-config-dump
file renamed
+2 -2
@@ -1,6 +1,6 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

+ from __future__ import absolute_import

  from __future__ import print_function

  

  import argparse
@@ -206,7 +206,7 @@ 

      )

  

  

- if __name__ == "__main__":

+ def cli_main():

      try:

          if not main():

              sys.exit(1)

pungi/scripts/config_validate.py bin/pungi-config-validate
file renamed
+2 -7
@@ -1,6 +1,6 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

+ from __future__ import absolute_import

  from __future__ import print_function

  

  import argparse
@@ -10,11 +10,6 @@ 

  

  import six

  

- here = sys.path[0]

- if here != '/usr/bin':

-     # Git checkout

-     sys.path[0] = os.path.dirname(here)

- 

  import pungi.checks

  import pungi.compose

  import pungi.paths
@@ -187,6 +182,6 @@ 

      return bool(errors)

  

  

- if __name__ == '__main__':

+ def cli_main():

      if main():

          sys.exit(1)

pungi/scripts/create_unified_isos.py bin/pungi-create-unified-isos
file renamed
-9
@@ -1,4 +1,3 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

  """
@@ -11,10 +10,6 @@ 

  import os

  import sys

  

- here = sys.path[0]

- if here != '/usr/bin':

-     # Git checkout

-     sys.path[0] = os.path.dirname(here)

  

  from pungi_utils.unified_isos import UnifiedISO

  
@@ -36,7 +31,3 @@ 

      args = parse_args()

      iso = UnifiedISO(args.compose[0])

      iso.create(delete_temp=True)

- 

- 

- if __name__ == '__main__':

-     main()

pungi/scripts/fedmsg_notification.py bin/pungi-fedmsg-notification
file renamed
+2 -2
@@ -1,4 +1,3 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

  import argparse
@@ -12,7 +11,8 @@ 

      topic = 'compose.%s' % cmd.replace('-', '.').lower()

      fedmsg.publish(topic=topic, modname='pungi', msg=data)

  

- if __name__ == '__main__':

+ 

+ def main():

      parser = argparse.ArgumentParser()

      parser.add_argument('cmd')

      opts = parser.parse_args()

pungi/scripts/patch_iso.py bin/pungi-patch-iso
file renamed
+1 -7
@@ -1,4 +1,3 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

  # This program is free software; you can redistribute it and/or modify
@@ -18,11 +17,6 @@ 

  import os

  import sys

  

- here = sys.path[0]

- if here != '/usr/bin':

-     # Git checkout

-     sys.path[0] = os.path.dirname(here)

- 

  from pungi_utils import patch_iso

  

  
@@ -52,6 +46,6 @@ 

      patch_iso.run(log, opts)

  

  

- if __name__ == '__main__':

+ def cli_main():

      if main():

          sys.exit(1)

file renamed
+147 -158
@@ -1,4 +1,3 @@ 

- #!/usr/bin/env python

  # This program is free software; you can redistribute it and/or modify

  # it under the terms of the GNU General Public License as published by

  # the Free Software Foundation; version 2 of the License.
@@ -11,16 +10,14 @@ 

  # You should have received a copy of the GNU General Public License

  # along with this program; if not, see <https://gnu.org/licenses/>.

  

+ from __future__ import absolute_import

  from __future__ import print_function

  

  import os

  import selinux

  import sys

  

- here = sys.path[0]

- if here != '/usr/bin':

-     # Git checkout

-     sys.path.insert(1, os.path.dirname(here))

+ from argparse import ArgumentParser, Action

  

  from pungi import get_full_version

  import pungi.gather
@@ -28,6 +25,151 @@ 

  import pungi.ks

  

  

+ def get_arguments(config):

+     parser = ArgumentParser()

+ 

+     class SetConfig(Action):

+         def __call__(self, parser, namespace, value, option_string=None):

+             config.set('pungi', self.dest, value)

+ 

+     parser.add_argument('--version', action='version', version=get_full_version())

+ 

+     # Pulled in from config file to be cli options as part of pykickstart conversion

+     parser.add_argument(

+         "--name", dest="family", type=str, action=SetConfig,

+         help='the name for your distribution (defaults to "Fedora"), DEPRECATED')

+     parser.add_argument(

+         "--family", dest="family", action=SetConfig,

+         help='the family name for your distribution (defaults to "Fedora")')

+     parser.add_argument(

+         "--ver", dest="version", action=SetConfig,

+         help='the version of your distribution (defaults to datestamp)')

+     parser.add_argument(

+         "--flavor", dest="variant", action=SetConfig,

+         help='the flavor of your distribution spin (optional), DEPRECATED')

+     parser.add_argument(

+         "--variant", dest="variant", action=SetConfig,

+         help='the variant of your distribution spin (optional)')

+     parser.add_argument(

+         "--destdir", dest="destdir", action=SetConfig,

+         help='destination directory (defaults to current directory)')

+     parser.add_argument(

+         "--cachedir", dest="cachedir", action=SetConfig,

+         help='package cache directory (defaults to /var/cache/pungi)')

+     parser.add_argument(

+         "--bugurl", dest="bugurl", action=SetConfig,

+         help='the url for your bug system (defaults to http://bugzilla.redhat.com)')

+     parser.add_argument(

+         "--selfhosting", action="store_true", dest="selfhosting",

+         help='build a self-hosting tree by following build dependencies (optional)')

+     parser.add_argument(

+         "--fulltree", action="store_true", dest="fulltree",

+         help='build a tree that includes all packages built from corresponding source rpms (optional)')

+     parser.add_argument(

+         "--nosource", action="store_true", dest="nosource",

+         help='disable gathering of source packages (optional)')

+     parser.add_argument(

+         "--nodebuginfo", action="store_true", dest="nodebuginfo",

+         help='disable gathering of debuginfo packages (optional)')

+     parser.add_argument(

+         "--nodownload", action="store_true", dest="nodownload",

+         help='disable downloading of packages. instead, print the package URLs (optional)')

+     parser.add_argument(

+         "--norelnotes", action="store_true", dest="norelnotes",

+         help='disable gathering of release notes (optional); DEPRECATED')

+     parser.add_argument(

+         "--nogreedy", action="store_true", dest="nogreedy",

+         help='disable pulling of all providers of package dependencies (optional)')

+     parser.add_argument(

+         "--nodeps", action="store_false", dest="resolve_deps", default=True,

+         help='disable resolving dependencies')

+     parser.add_argument(

+         "--sourceisos", default=False, action="store_true", dest="sourceisos",

+         help='Create the source isos (other arch runs must be done)')

+     parser.add_argument(

+         "--force", default=False, action="store_true",

+         help='Force reuse of an existing destination directory (will overwrite files)')

+     parser.add_argument(

+         "--isfinal", default=False, action="store_true",

+         help='Specify this is a GA tree, which causes betanag to be turned off during install')

+     parser.add_argument(

+         "--nohash", default=False, action="store_true",

+         help='disable hashing the Packages trees')

+     parser.add_argument(

+         "--full-archlist", action="store_true",

+         help='Use the full arch list for x86_64 (include i686, i386, etc.)')

+     parser.add_argument("--arch", help='Override default (uname based) arch')

+     parser.add_argument(

+         "--greedy", metavar="METHOD",

+         help='Greedy method; none, all, build')

+     parser.add_argument(

+         "--multilib", action="append", metavar="METHOD",

+         help='Multilib method; can be specified multiple times; recommended: devel, runtime')

+     parser.add_argument(

+         "--lookaside-repo", action="append", dest="lookaside_repos", metavar="NAME",

+         help='Specify lookaside repo name(s) (packages will used for depsolving but not be included in the output)')

+     parser.add_argument(

+         "--workdirbase", dest="workdirbase", action=SetConfig,

+         help='base working directory (defaults to destdir + /work)')

+     parser.add_argument("--no-dvd", default=False, action="store_true", dest="no_dvd",

+                         help='Do not make a install DVD/CD only the netinstall image and the tree')

+     parser.add_argument("--lorax-conf",

+                         help='Path to lorax.conf file (optional)')

+     parser.add_argument(

+         "-i", "--installpkgs", default=[], action="append", metavar="STRING",

+         help="Package glob for lorax to install before runtime-install.tmpl runs. (may be listed multiple times)")

+     parser.add_argument(

+         "--multilibconf", default=None, action=SetConfig,

+         help="Path to multilib conf files. Default is /usr/share/pungi/multilib/")

+ 

+     parser.add_argument("-c", "--config", dest="config", required=True,

+                         help='Path to kickstart config file')

+     parser.add_argument("--all-stages", action="store_true", default=True, dest="do_all",

+                         help="Enable ALL stages")

+     parser.add_argument("-G", action="store_true", default=False, dest="do_gather",

+                         help="Flag to enable processing the Gather stage")

+     parser.add_argument("-C", action="store_true", default=False, dest="do_createrepo",

+                         help="Flag to enable processing the Createrepo stage")

+     parser.add_argument("-B", action="store_true", default=False, dest="do_buildinstall",

+                         help="Flag to enable processing the BuildInstall stage")

+     parser.add_argument("-I", action="store_true", default=False, dest="do_createiso",

+                         help="Flag to enable processing the CreateISO stage")

+     parser.add_argument("--relnotepkgs", dest="relnotepkgs", action=SetConfig,

+                         help='Rpms which contain the release notes')

+     parser.add_argument(

+         "--relnotefilere", dest="relnotefilere", action=SetConfig,

+         help='Which files are the release notes -- GPL EULA')

+     parser.add_argument("--nomacboot", action="store_true", dest="nomacboot",

+                         help='disable setting up macboot as no hfs support ')

+ 

+     parser.add_argument(

+         "--rootfs-size", dest="rootfs_size", action=SetConfig, default=False,

+         help='Size of root filesystem in GiB. If not specified, use lorax default value')

+ 

+     parser.add_argument(

+         "--pungirc", dest="pungirc", default='~/.pungirc', action=SetConfig,

+         help='Read pungi options from config file ')

+ 

+     opts = parser.parse_args()

+ 

+     if not config.get('pungi', 'variant').isalnum() and not config.get('pungi', 'variant') == '':

+         parser.error("Variant must be alphanumeric")

+ 

+     if opts.do_gather or opts.do_createrepo or opts.do_buildinstall or opts.do_createiso:

+         opts.do_all = False

+ 

+     if opts.arch and (opts.do_all or opts.do_buildinstall):

+         parser.error("Cannot override arch while the BuildInstall stage is enabled")

+ 

+     # set the iso_basename.

+     if not config.get('pungi', 'variant') == '':

+         config.set('pungi', 'iso_basename', '%s-%s' % (config.get('pungi', 'family'), config.get('pungi', 'variant')))

+     else:

+         config.set('pungi', 'iso_basename', config.get('pungi', 'family'))

+ 

+     return opts

+ 

+ 

  def main():

  

      config = pungi.config.Config()
@@ -207,156 +349,3 @@ 

              mypungi.doCreateIsos()

  

      print("All done!")

- 

- if __name__ == '__main__':

-     from argparse import ArgumentParser, Action

-     import sys

-     import time

- 

-     today = time.strftime('%Y%m%d', time.localtime())

- 

-     def get_arguments(config):

-         parser = ArgumentParser()

- 

-         class SetConfig(Action):

-             def __call__(self, parser, namespace, value, option_string=None):

-                 config.set('pungi', self.dest, value)

- 

-         parser.add_argument('--version', action='version', version=get_full_version())

- 

-         # Pulled in from config file to be cli options as part of pykickstart conversion

-         parser.add_argument(

-             "--name", dest="family", type=str, action=SetConfig,

-             help='the name for your distribution (defaults to "Fedora"), DEPRECATED')

-         parser.add_argument(

-             "--family", dest="family", action=SetConfig,

-             help='the family name for your distribution (defaults to "Fedora")')

-         parser.add_argument(

-             "--ver", dest="version", action=SetConfig,

-             help='the version of your distribution (defaults to datestamp)')

-         parser.add_argument(

-             "--flavor", dest="variant", action=SetConfig,

-             help='the flavor of your distribution spin (optional), DEPRECATED')

-         parser.add_argument(

-             "--variant", dest="variant", action=SetConfig,

-             help='the variant of your distribution spin (optional)')

-         parser.add_argument(

-             "--destdir", dest="destdir", action=SetConfig,

-             help='destination directory (defaults to current directory)')

-         parser.add_argument(

-             "--cachedir", dest="cachedir", action=SetConfig,

-             help='package cache directory (defaults to /var/cache/pungi)')

-         parser.add_argument(

-             "--bugurl", dest="bugurl", action=SetConfig,

-             help='the url for your bug system (defaults to http://bugzilla.redhat.com)')

-         parser.add_argument(

-             "--selfhosting", action="store_true", dest="selfhosting",

-             help='build a self-hosting tree by following build dependencies (optional)')

-         parser.add_argument(

-             "--fulltree", action="store_true", dest="fulltree",

-             help='build a tree that includes all packages built from corresponding source rpms (optional)')

-         parser.add_argument(

-             "--nosource", action="store_true", dest="nosource",

-             help='disable gathering of source packages (optional)')

-         parser.add_argument(

-             "--nodebuginfo", action="store_true", dest="nodebuginfo",

-             help='disable gathering of debuginfo packages (optional)')

-         parser.add_argument(

-             "--nodownload", action="store_true", dest="nodownload",

-             help='disable downloading of packages. instead, print the package URLs (optional)')

-         parser.add_argument(

-             "--norelnotes", action="store_true", dest="norelnotes",

-             help='disable gathering of release notes (optional); DEPRECATED')

-         parser.add_argument(

-             "--nogreedy", action="store_true", dest="nogreedy",

-             help='disable pulling of all providers of package dependencies (optional)')

-         parser.add_argument(

-             "--nodeps", action="store_false", dest="resolve_deps", default=True,

-             help='disable resolving dependencies')

-         parser.add_argument(

-             "--sourceisos", default=False, action="store_true", dest="sourceisos",

-             help='Create the source isos (other arch runs must be done)')

-         parser.add_argument(

-             "--force", default=False, action="store_true",

-             help='Force reuse of an existing destination directory (will overwrite files)')

-         parser.add_argument(

-             "--isfinal", default=False, action="store_true",

-             help='Specify this is a GA tree, which causes betanag to be turned off during install')

-         parser.add_argument(

-             "--nohash", default=False, action="store_true",

-             help='disable hashing the Packages trees')

-         parser.add_argument(

-             "--full-archlist", action="store_true",

-             help='Use the full arch list for x86_64 (include i686, i386, etc.)')

-         parser.add_argument("--arch", help='Override default (uname based) arch')

-         parser.add_argument(

-             "--greedy", metavar="METHOD",

-             help='Greedy method; none, all, build')

-         parser.add_argument(

-             "--multilib", action="append", metavar="METHOD",

-             help='Multilib method; can be specified multiple times; recommended: devel, runtime')

-         parser.add_argument(

-             "--lookaside-repo", action="append", dest="lookaside_repos", metavar="NAME",

-             help='Specify lookaside repo name(s) (packages will used for depsolving but not be included in the output)')

-         parser.add_argument(

-             "--workdirbase", dest="workdirbase", action=SetConfig,

-             help='base working directory (defaults to destdir + /work)')

-         parser.add_argument("--no-dvd", default=False, action="store_true", dest="no_dvd",

-                             help='Do not make a install DVD/CD only the netinstall image and the tree')

-         parser.add_argument("--lorax-conf",

-                             help='Path to lorax.conf file (optional)')

-         parser.add_argument(

-             "-i", "--installpkgs", default=[], action="append", metavar="STRING",

-             help="Package glob for lorax to install before runtime-install.tmpl runs. (may be listed multiple times)")

-         parser.add_argument(

-             "--multilibconf", default=None, action=SetConfig,

-             help="Path to multilib conf files. Default is /usr/share/pungi/multilib/")

- 

-         parser.add_argument("-c", "--config", dest="config", required=True,

-                             help='Path to kickstart config file')

-         parser.add_argument("--all-stages", action="store_true", default=True, dest="do_all",

-                             help="Enable ALL stages")

-         parser.add_argument("-G", action="store_true", default=False, dest="do_gather",

-                             help="Flag to enable processing the Gather stage")

-         parser.add_argument("-C", action="store_true", default=False, dest="do_createrepo",

-                             help="Flag to enable processing the Createrepo stage")

-         parser.add_argument("-B", action="store_true", default=False, dest="do_buildinstall",

-                             help="Flag to enable processing the BuildInstall stage")

-         parser.add_argument("-I", action="store_true", default=False, dest="do_createiso",

-                             help="Flag to enable processing the CreateISO stage")

-         parser.add_argument("--relnotepkgs", dest="relnotepkgs", action=SetConfig,

-                             help='Rpms which contain the release notes')

-         parser.add_argument(

-             "--relnotefilere", dest="relnotefilere", action=SetConfig,

-             help='Which files are the release notes -- GPL EULA')

-         parser.add_argument("--nomacboot", action="store_true", dest="nomacboot",

-                             help='disable setting up macboot as no hfs support ')

- 

-         parser.add_argument(

-             "--rootfs-size", dest="rootfs_size", action=SetConfig, default=False,

-             help='Size of root filesystem in GiB. If not specified, use lorax default value')

- 

-         parser.add_argument(

-             "--pungirc", dest="pungirc", default='~/.pungirc', action=SetConfig,

-             help='Read pungi options from config file ')

- 

-         opts = parser.parse_args()

- 

-         if not config.get('pungi', 'variant').isalnum() and not config.get('pungi', 'variant') == '':

-             parser.error("Variant must be alphanumeric")

- 

-         if opts.do_gather or opts.do_createrepo or opts.do_buildinstall or opts.do_createiso:

-             opts.do_all = False

- 

-         if opts.arch and (opts.do_all or opts.do_buildinstall):

-             parser.error("Cannot override arch while the BuildInstall stage is enabled")

- 

-         # set the iso_basename.

-         if not config.get('pungi', 'variant') == '':

-             config.set('pungi', 'iso_basename', '%s-%s' % (config.get('pungi', 'family'), config.get('pungi', 'variant')))

-         else:

-             config.set('pungi', 'iso_basename', config.get('pungi', 'family'))

- 

-         return opts

- 

-     main()

file renamed
+2 -2
@@ -1,6 +1,6 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

+ from __future__ import absolute_import

  from __future__ import print_function

  

  import argparse
@@ -176,7 +176,7 @@ 

          print("SRPM%s: %s" % (_get_flags(gather_obj, pkg), _get_url(pkg)))

  

  

- if __name__ == "__main__":

+ def cli_main():

      parser = get_parser()

      ns = parser.parse_args()

  

file renamed
+2 -7
@@ -1,6 +1,6 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

+ from __future__ import absolute_import

  from __future__ import print_function

  

  import argparse
@@ -17,11 +17,6 @@ 

  

  from six.moves import shlex_quote

  

- here = sys.path[0]

- if here != '/usr/bin':

-     # Git checkout

-     sys.path[0] = os.path.dirname(here)

- 

  from pungi.phases import PHASES_NAMES

  from pungi import get_full_version, util

  
@@ -479,7 +474,7 @@ 

      sys.exit(1)

  

  

- if __name__ == "__main__":

+ def cli_main():

      signal.signal(signal.SIGTERM, sigterm_handler)

  

      try:

pungi/scripts/report_progress.py bin/pungi-notification-report-progress
file renamed
+1 -3
@@ -1,5 +1,3 @@ 

- #!/usr/bin/env python

- 

  from __future__ import print_function

  

  import argparse
@@ -8,7 +6,7 @@ 

  import sys

  

  

- if __name__ == '__main__':

+ def main():

      parser = argparse.ArgumentParser()

      parser.add_argument('cmd')

      opts = parser.parse_args()

pungi/scripts/wait_for_signed_ostree_handler.py bin/pungi-wait-for-signed-ostree-handler
file renamed
+1 -2
@@ -1,4 +1,3 @@ 

- #!/usr/bin/env python

  # -*- coding: utf-8 -*-

  

  """
@@ -38,7 +37,7 @@ 

      print("%s: %s" % (datetime.datetime.utcnow(), msg))

  

  

- if __name__ == '__main__':

+ def main():

      parser = argparse.ArgumentParser()

      parser.add_argument('cmd')

      opts = parser.parse_args()

file modified
+17 -14
@@ -33,21 +33,24 @@ 

      license         = "GPLv2",

  

      packages        = packages,

+     entry_points    = {

+         'console_scripts': [

+             'comps_filter = pungi.scripts.comps_filter:main',

+             'pungi = pungi.scripts.pungi:main',

+             'pungi-create-unified-isos = pungi.scripts.create_unified_isos:main',

+             'pungi-fedmsg-notification = pungi.scripts.fedmsg_notification:main',

+             'pungi-patch-iso = pungi.scripts.patch_iso:cli_main',

+             'pungi-make-ostree = pungi.ostree:main',

+             'pungi-notification-report-progress = pungi.scripts.report_progress:main',

+             'pungi-orchestrate = pungi_utils.orchestrator:main',

+             'pungi-wait-for-signed-ostree-handler = pungi.scripts.wait_for_signed_ostree_handler:main',

+             'pungi-koji = pungi.scripts.pungi_koji:cli_main',

+             'pungi-gather = pungi.scripts.pungi_gather:cli_main',

+             'pungi-config-dump = pungi.scripts.config_dump:cli_main',

+             'pungi-config-validate = pungi.scripts.config_validate:cli_main',

+         ]

+     },

      scripts         = [

-         'bin/comps_filter',

-         'bin/pungi',

-         'bin/pungi-config-dump',

-         'bin/pungi-config-validate',

-         'bin/pungi-create-unified-isos',

-         'bin/pungi-fedmsg-notification',

-         'bin/pungi-gather',

-         'bin/pungi-koji',

-         'bin/pungi-make-ostree',

-         'bin/pungi-notification-report-progress',

-         'bin/pungi-orchestrate',

-         'bin/pungi-patch-iso',

-         'bin/pungi-wait-for-signed-ostree-handler',

- 

          'contrib/yum-dnf-compare/pungi-compare-depsolving',

      ],

      data_files      = [

file modified
-4
@@ -275,10 +275,6 @@ 

      return conf

  

  

- def load_bin(name):

-     return imp.load_source('pungi_cli_fake_' + name, os.path.dirname(__file__) + "/../bin/" + name)

- 

- 

  def fake_run_in_threads(func, params, threads=None):

      """Like run_in_threads from Kobo, but actually runs tasks serially."""

      for num, param in enumerate(params):

file modified
-2
@@ -6,8 +6,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.arch import (get_compatible_arches, get_valid_arches, get_valid_multilib_arches,

                          is_excluded, is_valid_arch, split_name_arch)

  

file modified
+5 -6
@@ -5,9 +5,7 @@ 

      import unittest

  import six

  

- from tests.helpers import load_bin

- 

- cli = load_bin("pungi-koji")

+ from pungi.scripts.pungi_koji import cli_main

  

  

  class PungiKojiTestCase(unittest.TestCase):
@@ -15,10 +13,11 @@ 

      @mock.patch('sys.argv', new=['prog', '--version'])

      @mock.patch('sys.stderr', new_callable=six.StringIO)

      @mock.patch('sys.stdout', new_callable=six.StringIO)

-     @mock.patch('pungi_cli_fake_pungi-koji.get_full_version', return_value='a-b-c.111')

+     @mock.patch('pungi.scripts.pungi_koji.get_full_version', return_value='a-b-c.111')

      def test_version(self, get_full_version, stdout, stderr):

-         with self.assertRaises(SystemExit):

-             cli.main()

+         with self.assertRaises(SystemExit) as cm:

+             cli_main()

+         self.assertEqual(cm.exception.code, 0)

          # Python 2.7 prints the version to stderr, 3.4+ to stdout.

          if six.PY3:

              self.assertMultiLineEqual(stdout.getvalue(), 'a-b-c.111\n')

@@ -7,8 +7,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.buildinstall import (BuildinstallPhase, BuildinstallThread, link_boot_iso,

                                         BOOT_CONFIGS, tweak_configs)

  from tests.helpers import DummyCompose, PungiTestCase, touch

file modified
-2
@@ -11,8 +11,6 @@ 

  

  import kobo.conf

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from pungi import checks

  

  

file modified
-2
@@ -12,8 +12,6 @@ 

  import tempfile

  import shutil

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.compose import Compose

  

  

@@ -9,8 +9,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers.comps import CompsWrapper, CompsFilter, CompsValidationError

  from tests.helpers import BaseTestCase, FIXTURE_DIR

  

file modified
-2
@@ -11,8 +11,6 @@ 

  import sys

  import mock

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from pungi import checks

  from tests.helpers import load_config, PKGSET_REPOS

  

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

  

  from parameterized import parameterized

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi_utils import config_utils

  

  

@@ -1,30 +1,26 @@ 

  # -*- coding: utf-8 -*-

  

  

+ import mock

  import os

  import subprocess

  import sys

+ import six

  

+ from pungi.scripts.config_validate import cli_main

+ from tests import helpers

  

- HERE = os.path.abspath(os.path.dirname(__file__))

- BINDIR = os.path.join(HERE, '../bin')

- PUNGI_CONFIG_VALIDATE = os.path.join(BINDIR, 'pungi-config-validate')

- 

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

  

- from tests import helpers

+ HERE = os.path.abspath(os.path.dirname(__file__))

+ DUMMY_CONFIG = os.path.join(HERE, 'data/dummy-pungi.conf')

  

  

  class ConfigValidateScriptTest(helpers.PungiTestCase):

  

-     def test_validate_dummy_config(self):

-         DUMMY_CONFIG = os.path.join(HERE, 'data/dummy-pungi.conf')

-         p = subprocess.Popen(

-             [sys.executable, "-W", "ignore", PUNGI_CONFIG_VALIDATE, DUMMY_CONFIG],

-             stdout=subprocess.PIPE,

-             stderr=subprocess.PIPE,

-         )

-         (stdout, stderr) = p.communicate()

-         self.assertEqual(b'', stdout)

-         self.assertEqual(b'', stderr)

-         self.assertEqual(0, p.returncode)

+     @mock.patch('sys.argv', new=['pungi-config-validate', DUMMY_CONFIG])

+     @mock.patch('sys.stderr', new_callable=six.StringIO)

+     @mock.patch('sys.stdout', new_callable=six.StringIO)

+     def test_validate_dummy_config(self, stdout, stderr):

+         cli_main()

+         self.assertEqual('', stdout.getvalue())

+         self.assertEqual('', stderr.getvalue())

@@ -7,8 +7,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests import helpers

  from pungi.createiso import CreateIsoOpts

  from pungi.phases import createiso

@@ -6,8 +6,6 @@ 

  import sys

  from six.moves import StringIO

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests import helpers

  from pungi import createiso

  

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

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers.createrepo import CreaterepoWrapper

  

  

@@ -12,8 +12,6 @@ 

  import six

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.createrepo import (CreaterepoPhase,

                                       create_variant_repo,

                                       get_productids_from_scm,

@@ -8,8 +8,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases import extra_files

  from tests import helpers

  

@@ -7,8 +7,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests import helpers

  from pungi.phases import extra_isos

  

@@ -12,8 +12,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers import fus

  

  from .helpers import touch, PungiTestCase

file modified
-5
@@ -15,11 +15,6 @@ 

  

  from six.moves import cStringIO

  

- HERE = os.path.dirname(__file__)

- BINDIR = (os.path.join(HERE, '..', 'bin'))

- sys.path.insert(0, os.path.join(HERE, '..'))

- os.environ['PATH'] = '%s:%s' % (BINDIR, os.environ['PATH'])

- 

  from pungi.wrappers.pungi import PungiWrapper

  try:

      from pungi.dnf_wrapper import DnfWrapper, Conf

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

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.gather.methods import method_deps as deps

  from tests import helpers

  

@@ -8,8 +8,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.gather.methods import method_hybrid as hybrid

  from pungi.phases.pkgset.common import MaterializedPackageSet as PkgSet

  from tests import helpers

@@ -6,8 +6,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.gather.methods import method_nodeps as nodeps

  from tests import helpers

  

@@ -12,8 +12,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases import gather

  from pungi.phases.pkgset.common import MaterializedPackageSet

  from pungi.phases.gather import _mk_pkg_map

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

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.gather.sources.source_module import GatherSourceModule

  from tests import helpers

  from pungi.module_util import Modulemd

file modified
-2
@@ -10,8 +10,6 @@ 

  

  from pungi.graph import SimpleAcyclicOrientedGraph

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  

  class SimpleAcyclicOrientedGraphTestCase(unittest.TestCase):

  

@@ -7,8 +7,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.image_build import ImageBuildPhase, CreateImageBuildThread

  from tests.helpers import DummyCompose, PungiTestCase, boom

  

@@ -11,8 +11,6 @@ 

  import tempfile

  import shutil

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.image_checksum import ImageChecksumPhase, dump_checksums

  from tests.helpers import DummyCompose, PungiTestCase

  

file modified
-2
@@ -12,8 +12,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.module_util import Modulemd

  from pungi.phases import init

  from tests.helpers import DummyCompose, PungiTestCase, touch, mk_boom, fake_run_in_threads

@@ -9,8 +9,6 @@ 

  except ImportError:

      import unittest

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers import iso

  

  CORRECT_OUTPUT = '''dummy.iso:   31ff3e405e26ad01c63b62f6b11d30f6

@@ -13,8 +13,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers.kojiwrapper import KojiWrapper, get_buildroot_rpms

  

  from .helpers import FIXTURE_DIR

file modified
-2
@@ -7,8 +7,6 @@ 

  import stat

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi import linker

  from tests import helpers

  

@@ -8,8 +8,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.live_images import LiveImagesPhase, CreateLiveImageThread

  from tests.helpers import DummyCompose, PungiTestCase, boom

  

@@ -7,8 +7,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.livemedia_phase import LiveMediaPhase, LiveMediaThread

  from tests.helpers import DummyCompose, PungiTestCase, boom

  

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

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers.lorax import LoraxWrapper

  

  

@@ -8,8 +8,6 @@ 

  import sys

  import mock

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from pungi import media_split

  

  

file modified
-2
@@ -4,8 +4,6 @@ 

  

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from tests import helpers

  

  from pungi import metadata

file modified
-2
@@ -10,8 +10,6 @@ 

  except ImportError:

      import unittest

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.notifier import PungiNotifier

  

  

@@ -16,8 +16,6 @@ 

  

  from parameterized import parameterized

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from tests.helpers import BaseTestCase, PungiTestCase, touch, FIXTURE_DIR

  from pungi_utils import orchestrator as o

  

@@ -7,8 +7,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests import helpers

  from pungi import checks

  from pungi.phases import osbs

@@ -7,8 +7,6 @@ 

  

  from kobo.shortcuts import force_list

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests import helpers

  from pungi.phases import ostree_installer as ostree

  from six.moves import shlex_quote

@@ -7,8 +7,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests import helpers

  from pungi.phases import ostree

  

@@ -9,9 +9,6 @@ 

  import six

  import yaml

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), 'bin'))

- 

  from tests import helpers

  from pungi import ostree

  

@@ -5,8 +5,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests import helpers

  from pungi.ostree import utils

  

file modified
-2
@@ -8,8 +8,6 @@ 

  except ImportError:

      import unittest

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests.helpers import boom, touch, copy_fixture

  from pungi_utils import patch_iso

  

file modified
-2
@@ -5,8 +5,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.pathmatch import PathMatch, head_tail_split

  

  

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

  import sys

  import time

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases import weaver

  from tests.helpers import DummyCompose, boom

  

@@ -6,8 +6,6 @@ 

  import mock

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.module_util import Modulemd

  from pungi.phases.pkgset import common

  from tests import helpers

@@ -13,8 +13,6 @@ 

  import re

  from dogpile.cache import make_region

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.pkgset import pkgsets

  from tests import helpers

  

@@ -11,8 +11,6 @@ 

  except ImportError:

      import unittest

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.phases.pkgset.sources import source_koji

  from tests import helpers

  from pungi.module_util import Modulemd

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

  import sys

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers import repoclosure as rc

  

  from . import helpers

file modified
-2
@@ -4,8 +4,6 @@ 

  import os

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.runroot import Runroot

  from tests import helpers

  

file modified
-2
@@ -12,8 +12,6 @@ 

  import sys

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers import scm

  from tests.helpers import touch

  

@@ -11,8 +11,6 @@ 

  import six

  import sys

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  import pungi.phases.test as test_phase

  from tests.helpers import DummyCompose, PungiTestCase, touch, mk_boom

  

@@ -7,8 +7,6 @@ 

  import six

  from six.moves.configparser import SafeConfigParser

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

- 

  from tests.helpers import PungiTestCase, FIXTURE_DIR, touch, mk_boom

  from pungi_utils import unified_isos

  

file modified
-2
@@ -13,8 +13,6 @@ 

  import subprocess

  import six

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi import compose

  from pungi import util

  

@@ -8,8 +8,6 @@ 

  import sys

  from six.moves import cStringIO

  

- sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))

- 

  from pungi.wrappers.variants import VariantsXmlParser

  

  VARIANTS_WITH_WHITESPACE = """

Fixes: https://pagure.io/pungi/issue/1045
JIRA: COMPOSE-2946
Signed-off-by: Haibo Lin hlin@redhat.com

rebased onto ed52dc07e165581f60e7d9e4e370e205efe5a87d

4 years ago

rebased onto bbec25ee25b0807e3d7b81aa44551f0a7e19c94a

4 years ago

In this particular function there is a problem. This horrible function defines a get_arguments function, that previously was available in global scope and could be called from main(). I'm not sure why it was this complex, there doesn't seem to be any requirement for such monstrosity.

Generally looks good to me. Are the absolute_imports required?

In this particular function there is a problem. This horrible function defines a get_arguments function, that previously was available in global scope and could be called from main(). I'm not sure why it was this complex, there doesn't seem to be any requirement for such monstrosity.

Fixed.

Generally looks good to me. Are the absolute_imports required?

It's required with python2 unless renaming pungi/scripts/pungi.py, but I don't find a proper name yet.

pretty please pagure-ci rebuild

4 years ago

Verified, that I can run the tests after change.

It's required with python2 unless renaming pungi/scripts/pungi.py, but I don't find a proper name yet.

Right, that makes sense. This script is basically what was pungi 3 originally, and it's still used in gather method as yum backend.

Looks good to me. :thumbsup:

Pull-Request has been merged by lsedlar

4 years ago
Changes Summary 71
-15
file removed
bin/pungi-make-ostree
-16
file removed
bin/pungi-orchestrate
+1 -0
file changed
doc/contributing.rst
+0
file added
pungi/scripts/__init__.py
+1 -5
file renamed
bin/comps_filter
pungi/scripts/comps_filter.py
+2 -2
file renamed
bin/pungi-config-dump
pungi/scripts/config_dump.py
+2 -7
file renamed
bin/pungi-config-validate
pungi/scripts/config_validate.py
+0 -9
file renamed
bin/pungi-create-unified-isos
pungi/scripts/create_unified_isos.py
+2 -2
file renamed
bin/pungi-fedmsg-notification
pungi/scripts/fedmsg_notification.py
+1 -7
file renamed
bin/pungi-patch-iso
pungi/scripts/patch_iso.py
+147 -158
file renamed
bin/pungi
pungi/scripts/pungi.py
+2 -2
file renamed
bin/pungi-gather
pungi/scripts/pungi_gather.py
+2 -7
file renamed
bin/pungi-koji
pungi/scripts/pungi_koji.py
+1 -3
file renamed
bin/pungi-notification-report-progress
pungi/scripts/report_progress.py
+1 -2
file renamed
bin/pungi-wait-for-signed-ostree-handler
pungi/scripts/wait_for_signed_ostree_handler.py
+17 -14
file changed
setup.py
+0 -4
file changed
tests/helpers.py
+0 -2
file changed
tests/test_arch.py
+5 -6
file changed
tests/test_arguments.py
+0 -2
file changed
tests/test_buildinstall.py
+0 -2
file changed
tests/test_checks.py
+0 -2
file changed
tests/test_compose.py
+0 -2
file changed
tests/test_comps_wrapper.py
+0 -2
file changed
tests/test_config.py
+0 -2
file changed
tests/test_config_utils.py
+13 -17
file changed
tests/test_config_validate_script.py
+0 -2
file changed
tests/test_createiso_phase.py
+0 -2
file changed
tests/test_createiso_script.py
+0 -2
file changed
tests/test_createrepo_wrapper.py
+0 -2
file changed
tests/test_createrepophase.py
+0 -2
file changed
tests/test_extra_files_phase.py
+0 -2
file changed
tests/test_extra_isos_phase.py
+0 -2
file changed
tests/test_fus_wrapper.py
+0 -5
file changed
tests/test_gather.py
+0 -2
file changed
tests/test_gather_method_deps.py
+0 -2
file changed
tests/test_gather_method_hybrid.py
+0 -2
file changed
tests/test_gather_method_nodeps.py
+0 -2
file changed
tests/test_gather_phase.py
+0 -2
file changed
tests/test_gather_source_module.py
+0 -2
file changed
tests/test_graph.py
+0 -2
file changed
tests/test_imagebuildphase.py
+0 -2
file changed
tests/test_imagechecksumphase.py
+0 -2
file changed
tests/test_initphase.py
+0 -2
file changed
tests/test_iso_wrapper.py
+0 -2
file changed
tests/test_koji_wrapper.py
+0 -2
file changed
tests/test_linker.py
+0 -2
file changed
tests/test_liveimagesphase.py
+0 -2
file changed
tests/test_livemediaphase.py
+0 -2
file changed
tests/test_lorax_wrapper.py
+0 -2
file changed
tests/test_media_split.py
+0 -2
file changed
tests/test_metadata.py
+0 -2
file changed
tests/test_notifier.py
+0 -2
file changed
tests/test_orchestrator.py
+0 -2
file changed
tests/test_osbs_phase.py
+0 -2
file changed
tests/test_ostree_installer_phase.py
+0 -2
file changed
tests/test_ostree_phase.py
+0 -3
file changed
tests/test_ostree_script.py
+0 -2
file changed
tests/test_ostree_utils.py
+0 -2
file changed
tests/test_patch_iso.py
+0 -2
file changed
tests/test_pathmatch.py
+0 -2
file changed
tests/test_phase_base.py
+0 -2
file changed
tests/test_pkgset_common.py
+0 -2
file changed
tests/test_pkgset_pkgsets.py
+0 -2
file changed
tests/test_pkgset_source_koji.py
+0 -2
file changed
tests/test_repoclosure_wrapper.py
+0 -2
file changed
tests/test_runroot.py
+0 -2
file changed
tests/test_scm.py
+0 -2
file changed
tests/test_test_phase.py
+0 -2
file changed
tests/test_unified_isos.py
+0 -2
file changed
tests/test_util.py
+0 -2
file changed
tests/test_variant_wrapper.py