def postOptions(self): """Post options processing """ if self['author'] is None: self['author'] = getpass.getuser() if self['email'] is not None: if not Checkers.check_email(self['email']): print( 'error: the given email address {} is not a valid RFC2822 ' 'email address, ' 'check http://www.rfc-editor.org/rfc/rfc2822.txt for ' 'very extended details'.format(self['email']) ) sys.exit(-1) else: # just set an invalid RFC2822 email address (thats what irony mean) self['email'] = '{}@localhost'.format(self['author']) if self['route'] is None: self['route'] = '' if self['platforms'] is None: self['platforms'] = 'Linux'
def postOptions(self): """Post options processing """ if ((self['user'] and self['global']) or (not self['user'] and not self['global'])): raise usage.UsageError( 'you must choose between `user` and `global` installations' ) if self['entry_points'] is not None: try: self['entry_points'] = json.loads(self['entry_points']) except ValueError: raise usage.UsageError('invalid JSON entry_points structure') if type(self['entry_points']) is not dict: raise usage.UsageError( 'the entry_points JSON string must be decoded as a dict' ) else: self['entry_points'] = {} if self['extra_directories'] is not None: try: self['extra_directories'] = json.loads( self['extra_directories'] ) except ValueError: raise usage.UsageError( 'invalid JSON extra_directories structure' ) if type(self['extra_directories']) is not list: raise usage.UsageError( 'the extra_directories JSON string ' 'must be decoded as a list' ) else: self['extra_directories'] = [] if self['author'] is None: self['author'] = getpass.getuser() if self['email'] is not None: if not Checkers.check_email(self['email']): print( 'error: the given email address {} is not a valid RFC2822 ' 'email address, ' 'check http://www.rfc-editor.org/rfc/rfc2822.txt for ' 'very extended details'.format(self['email']) ) sys.exit(-1) else: # just set an invalid RFC2822 email address (thats what irony mean) self['email'] = '{}@localhost'.format(self['author'])
def post_options(self): """Post options processing """ if self['author'] is None: self['author'] = getpass.getuser() if self['email'] is not None: if not Checkers.check_email(self['email']): print( 'error: the given email address {} is not a valid RFC2822 ' 'email address, ' 'check http://www.rfc-editor.org/rfc/rfc2822.txt for ' 'very extended details'.format(self['email']) ) sys.exit(-1) else: # just set an invalid RFC2822 email address (thats what irony mean) self['email'] = '{}@localhost'.format(self['author'])
def _check_register_errors(self, **kwargs): """ Just check common register errors The front-end JavaScript code is supossed to prevent any of those errors but we know we can't just trust JavaScript because it can be cheated or query can be faked """ errors = [] if 'name' not in kwargs: errors.append('Name is required') if 'email' not in kwargs: errors.append('Email is required') else: if not Checkers.check_email(kwargs['email']): errors.append('Email should be a valid email') if 'key' not in kwargs: kwargs['key'] = ''.join(random.choice( string.ascii_letters + string.digits) for x in range(12) ) success, fails = Checkers.check_password(kwargs['key']) if not success: for error in fails: errors.append(error) if kwargs['key'].count(kwargs['key'][0]) == len(kwargs['key']): errors.append( 'Key should be a real key not {letter} just repeated'.format( letter=kwargs['key'][0] ) ) if 'github_profile' in kwargs: # check if the given Github account really exists response = yield self._check_services_account( kwargs['github_profile'], 'github' ) if response.code == 404: errors.append('Non valid GitHub account provided') if 'bitbucket_profile' in kwargs: # check if teh given BitBucket account really exists response = yield self._check_services_account( kwargs['bitbucket_profile'], 'bitbucket' ) if response.code == 404: errors.append('Non valid BitBucket account provided') if 'twitter' in kwargs: # check if the given Twitter account exists response = yield self._check_services_account( kwargs['twitter'], 'twitter' ) if response.code == 404: errors.append('Non valid Twitter account provided') defer.returnValue(errors)