Exemple #1
0
    def invoke(self, ctx):
        try:
            self._check_for_new_version()
            self._check_for_error_collection_permission()
            return super(FandoghCommand, self).invoke(ctx)
        except CommandParameterException as exp:
            click.echo(format_text(exp.message, TextStyle.FAIL), err=True)
            exit(1)
        except FandoghAPIError as exp:
            debug('APIError. status code: {}, content: {}'.format(
                exp.response.status_code, exp.response.content))
            click.echo(format_text(exp.message, TextStyle.FAIL), err=True)
            exit(1)
        except VersionException as exp:
            click.echo(format_text(
                "New Version of {} is available, please update to continue "
                "using Fandogh services using : `pip install {} --upgrade`".
                format(NAME, NAME), TextStyle.FAIL),
                       err=True)
        except AuthenticationError:
            click.echo(format_text(
                "Please login first. You can do it by running 'fandogh login' command",
                TextStyle.FAIL),
                       err=True)

        except requests.exceptions.RequestException as req_err:
            click.echo(format_text(
                'Error in your network connection! trying again might help to fix this issue \n'
                'if it is keep happening, please inform us!', TextStyle.FAIL),
                       err=True)
            collect(self, ctx, req_err)
        except Exception as exp:
            collect(self, ctx, exp)
            raise exp
Exemple #2
0
 def zipdir(self, path, ziph):
     ignored_entries = self.get_ignored_entries()
     ignored_entries.append('*dockerignore')
     debug(ignored_entries)
     for root, dirs, files in os.walk(path):
         for file in files:
             if file != 'workspace.zip':
                 file_path = os.path.join(os.path.relpath(root, path), file)
                 if (file != self.docker_file_name and any(
                         fnmatch(file_path, ignore.strip())
                         for ignore in ignored_entries)):
                     debug('{} filtered out.'.format(file_path))
                     continue
                 ziph.write(file_path)
Exemple #3
0
 def _check_for_new_version(self):
     latest_version = self._get_latest_version()
     version_diff = get_current_version().compare(latest_version)
     if version_diff < -2:  # -1:Major -2:Minor -3:Patch
         click.echo(
             format_text(
                 "New version is available, "
                 "please update to new version"
                 " using `pip install {} --upgrade` to access latest bugfixes"
                 .format(NAME), TextStyle.WARNING))
         debug("New Version is available: {}".format(latest_version))
     elif version_diff < 0:
         debug("New Version is available: {}".format(latest_version))
         raise VersionException()
 def invoke(self, ctx):
     try:
         self._check_for_new_version()
         self._check_for_error_collection_permission()
         return super(FandoghCommand, self).invoke(ctx)
     except (FandoghAPIError, AuthenticationError) as exp:
         debug('APIError. status code: {}, content: {}'.format(
             exp.response.status_code, exp.response.content))
         click.echo(format_text(exp.message, TextStyle.FAIL), err=True)
         exit(1)
     except VersionException as exp:
         click.echo(
             format_text(
                 "New Version of {} is available, please update to continue "
                 "using Fandogh services using : `pip install {} --upgrade`"
                 .format(NAME, NAME), TextStyle.FAIL))
     except Exception as exp:
         collect(self, ctx, exp)
         raise exp