def run_gooey(self, args=None, namespace=None):
            # This import is delayed so it is not in the --ignore-gooey codepath.
            from gooey.gui import application
            source_path = sys.argv[0]

            build_spec = None
            if load_build_config:
                try:
                    exec_dir = os.path.dirname(sys.argv[0])
                    open_path = os.path.join(exec_dir, load_build_config)
                    build_spec = json.load(open(open_path, "r"))
                except Exception as e:
                    print(
                        'Exception loading Build Config from {0}: {1}'.format(
                            load_build_config, e))
                    sys.exit(1)

            if not build_spec:
                build_spec = config_generator.create_from_parser(
                    self, source_path, payload_name=payload.__name__, **params)

            if dump_build_config:
                config_path = os.path.join(os.path.dirname(sys.argv[0]),
                                           'gooey_config.json')
                print('Writing Build Config to: {}'.format(config_path))
                with open(config_path, 'w') as f:
                    f.write(json.dumps(build_spec, indent=2))
            application.run(build_spec)
Example #2
0
    def run_gooey(self, args=None, namespace=None):
      source_path = sys.argv[0]
      build_spec = config_generator.create_from_parser(self, source_path, payload_name=payload.__name__, **params)

      if dump_build_config:
        config_path = os.path.join(os.getcwd(), 'gooey_config.json')
        print( 'Writing Build Config to: {}'.format(config_path))
        with open(config_path, 'w') as f:
          f.write(json.dumps(build_spec, indent=2))
      application.run(build_spec)
Example #3
0
        def run_gooey(self, args=None, namespace=None):
            source_path = sys.argv[0]
            build_spec = config_generator.create_from_parser(
                self, source_path, payload_name=payload.__name__, **params)

            if dump_build_config:
                config_path = os.path.join(os.getcwd(), 'gooey_config.json')
                print('Writing Build Config to: {}'.format(config_path))
                with open(config_path, 'w') as f:
                    f.write(json.dumps(build_spec, indent=2))
            application.run(build_spec)
Example #4
0
    def run_gooey(self, args=None, namespace=None):
      # This import is delayed so it is not in the --ignore-gooey codepath.
      from gooey.gui import application
      source_path = sys.argv[0]

      build_spec = None
      if load_build_config:
        try:
          exec_dir = os.path.dirname(sys.argv[0])
          open_path = os.path.join(exec_dir,load_build_config)
          build_spec = json.load(open(open_path, "r"))
        except Exception as e:
          print( 'Exception loading Build Config from {0}: {1}'.format(load_build_config, e))
          sys.exit(1)

      if not build_spec:
        for action in self._actions:
          action.save_required = action.required
          action.required = False
          action.save_nargs = action.nargs
          if action.nargs == '+':
            action.nargs = '*'
          elif action.nargs is None:
            action.nargs = '?'
        for mutex_group in self._mutually_exclusive_groups:
          mutex_group.save_required = mutex_group.required
          mutex_group.required = False
        cmd_args = self.original_parse_args()
        for action in self._actions:
          action.required = action.save_required
          action.nargs = action.save_nargs
          dest = getattr(action, 'dest', None)
          if dest:
            cmd_arg = getattr(cmd_args, dest, None)
            if cmd_arg:
              action.default = cmd_arg
        for mutex_group in self._mutually_exclusive_groups:
          mutex_group.required = mutex_group.save_required

        build_spec = config_generator.create_from_parser(
          self,
          source_path,
          payload_name=payload.__name__,
          **params)

      if dump_build_config:
        config_path = os.path.join(os.path.dirname(sys.argv[0]), 'gooey_config.json')
        print('Writing Build Config to: {}'.format(config_path))
        with open(config_path, 'w') as f:
          f.write(json.dumps(build_spec, indent=2))
      application.run(build_spec)
Example #5
0
    def run_gooey(self, args=None, namespace=None):
      source_path = sys.argv[0]

      build_spec = None
      if load_build_config:
        try:
          build_spec = json.load(open(load_build_config, "r"))
        except Exception as e:
          print( 'Exception loading Build Config from {0}: {1}'.format(load_build_config, e))
          sys.exit(1)

      if not build_spec:
        build_spec = config_generator.create_from_parser(self, source_path, payload_name=payload.__name__, **params)

      if dump_build_config:
        config_path = os.path.join(os.getcwd(), 'gooey_config.json')
        print('Writing Build Config to: {}'.format(config_path))
        with open(config_path, 'w') as f:
          f.write(json.dumps(build_spec, indent=2))
      application.run(build_spec)
Example #6
0
  def build(payload):
    def run_gooey(self, args=None, namespace=None):
      source_path = sys.argv[0]

      build_spec = None
      if load_build_config:
        try:
          build_spec = json.load(open(load_build_config, "r"))
        except Exception, e:
          print( 'Exception loading Build Config from {0}: {1}'.format(load_build_config, e))
          sys.exit(1)

      if not build_spec:
        build_spec = config_generator.create_from_parser(self, source_path, payload_name=payload.__name__, **params)

      if dump_build_config:
        config_path = os.path.join(os.getcwd(), 'gooey_config.json')
        print 'Writing Build Config to: {}'.format(config_path)
        with open(config_path, 'w') as f:
          f.write(json.dumps(build_spec, indent=2))
      application.run(build_spec)
Example #7
0
    def inner():
      main_module_path = get_caller_path()
      _, filename = os.path.split(main_module_path)
      cleaned_source = clean_source(main_module_path)

      descriptor, tmp_filepath = tempfile.mkstemp(suffix='.py')
      atexit.register(cleanup, descriptor, tmp_filepath)

      with open(tmp_filepath, 'w') as f:
        f.write(cleaned_source)

      if not source_parser.has_argparse(cleaned_source):
        show_config = False

      build_spec = config_generator.create_from_module(tmp_filepath, payload_name=payload.__name__, **params)

      if dump_build_config:
        config_path = os.path.join(os.getcwd(), 'gooey_config.json')
        print 'Writing Build Config to: {}'.format(config_path)
        with open(config_path, 'w') as f:
          f.write(json.dumps(build_spec, indent=2))

      application.run(build_spec)