def base_install(cls, repopaths, dbobj, hook_name, filein): ''' Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed :arg dbobj: the DB object the hook uses to store the settings information. ''' for repopath in repopaths: if not os.path.exists(repopath): raise FileNotFoundException('Repo %s not found' % repopath) hook_files = os.path.join( os.path.dirname(os.path.realpath(__file__)), 'files') # Make sure the hooks folder exists hookfolder = os.path.join(repopath, 'hooks') if not os.path.exists(hookfolder): os.makedirs(hookfolder) # Install the hook itself hook_file = os.path.join(repopath, 'hooks', cls.hook_type + '.' + hook_name) if not os.path.exists(hook_file): os.symlink(os.path.join(hook_files, filein), hook_file)
def base_install(cls, repopaths, dbobj, hook_name, filein): """ Method called to install the hook for a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed :arg dbobj: the DB object the hook uses to store the settings information. """ if cls.runner: # In the case of a new-style hook (with a Runner), there is no # need to copy any files into place return for repopath in repopaths: if not os.path.exists(repopath): raise FileNotFoundException("Repo %s not found" % repopath) hook_files = os.path.join( os.path.dirname(os.path.realpath(__file__)), "files") # Make sure the hooks folder exists hookfolder = os.path.join(repopath, "hooks") if not os.path.exists(hookfolder): os.makedirs(hookfolder) # Install the hook itself hook_file = os.path.join(repopath, "hooks", cls.hook_type + "." + hook_name) if not os.path.exists(hook_file): os.symlink(os.path.join(hook_files, filein), hook_file)
def base_remove(cls, repopaths, hook_name): """ Method called to remove the hook of a project. :arg project: a ``pagure.model.Project`` object to which the hook should be installed """ for repopath in repopaths: if not os.path.exists(repopath): raise FileNotFoundException("Repo %s not found" % repopath) hook_path = os.path.join(repopath, "hooks", cls.hook_type + "." + hook_name) if os.path.exists(hook_path): os.unlink(hook_path)
def set_up(cls, project): """ Install the generic post-receive hook that allow us to call multiple post-receive hooks as set per plugin. """ repopath = os.path.join(pagure_config["TICKETS_FOLDER"], project.path) if not os.path.exists(repopath): raise FileNotFoundException("No such file: %s" % repopath) hook_files = os.path.join( os.path.dirname(os.path.realpath(__file__)), "files" ) # Make sure the hooks folder exists hookfolder = os.path.join(repopath, "hooks") if not os.path.exists(hookfolder): os.makedirs(hookfolder) # Install the main post-receive file postreceive = os.path.join(hookfolder, "post-receive") hook_file = os.path.join(hook_files, "post-receive") if not os.path.exists(postreceive): os.symlink(hook_file, postreceive)