def travis_permissions(cls): """ Set permissions in order to avoid issues before commiting. """ try: build_dir = environ['TRAVIS_BUILD_DIR'] commands = [ 'sudo chown -R travis:travis %s' % (build_dir), 'sudo chgrp -R travis %s' % (build_dir), 'sudo chmod -R g+rwX %s' % (build_dir), 'sudo chmod 777 -Rf %s.git' % (build_dir + directory_separator), r"sudo find %s -type d -exec chmod g+x '{}' \;" % (build_dir) ] for command in commands: Helpers.Command(command).execute() if Helpers.Command( 'git config core.sharedRepository').execute() == '': Helpers.Command( 'git config core.sharedRepository group').execute() except NameError: pass return
def git(cls): """ Update repository if cloned (git). """ if Settings.stable: Helpers.Command('git checkout master').execute() else: Helpers.Command('git checkout dev').execute() print(Helpers.Command('git pull').execute()) return
def restore_replace(self): """ Check if we need to replace ".gitignore" to ".keep". """ if path.isdir(self.base + '.git'): if Settings.script not in \ Helpers.Command('git remote show origin').execute(): return True return False return True
def __init__(self, file_to_install=None, data_to_install=None, production=False): Check() _path = getcwd() if not _path.endswith(directory_separator): _path += directory_separator self.path = _path if file_to_install is None: self.file_to_install = 'PyFunceble.py' else: self.file_to_install = file_to_install self.file_to_install = self.path + self.file_to_install self.production = production self.data_to_install = data_to_install if self.production and not Settings.quiet: print('\nDefault timeout: %s seconds' % self.default_values()['seconds_before_http_timeout']) print('Installation of default variables for production', end=" ") else: if not Settings.quiet: print('\n\nInstallation of working directory', end=" ") self.execute() regex_skip = r'\[PyFunceble\sskip\]|\[ci\sskip\]' if Helpers.Regex(Helpers.Command('git log -2').execute(), regex_skip, return_data=False).match() or self.production: Clean() Directory(self.production) if self.production and not Settings.quiet: print(Fore.CYAN + Style.BRIGHT + '\n\nThe production logic was successfully completed!') print('You can now distribute this repository.\n') else: if not Settings.quiet: print(Fore.CYAN + Style.BRIGHT + '\n\nThe installation was successfully completed!') print( "You can now use the script with '%s' or learn how to use it with '%s'\n" % # pylint: disable=line-too-long (Style.BRIGHT + './' + Settings.script + '.py [-OPTIONS]' + Style.RESET_ALL, Style.BRIGHT + './' + Settings.script + '.py --help' + Style.RESET_ALL))
def __init__(self): self.current_path = getcwd() self.destination = self.current_path + \ directory_separator + Settings.funilrys + '.' self.files = { 'script': 'PyFunceble.py', 'tool': 'tool.py', 'iana': 'iana-domains-db.json', 'dir_structure': 'dir_structure.json' } if path.isdir(self.current_path + directory_separator + '.git') and Settings.script in Helpers.Command( 'git remote show origin').execute(): self.git() else: if not self.same_version(True): for data in self.files: Helpers.File(self.current_path + directory_separator + self.files[data]).delete() rename( self.destination + self.files[data], self.current_path + directory_separator + self.files[data]) if not Settings.quiet: print('Checking version', end=' ') if self.same_version() and not Settings.quiet: print(Settings.done + '\n\nThe update was successfully completed!') else: if not Settings.quiet: print( Settings.error + '\nImpossible to update PyFunceble. Please report issue.' ) else: if not Settings.quiet: print('No need to update.\n') for data in self.files: Helpers.File(self.destination + self.files[data]).delete()