3 @qhcÖã@stddlmZddlmZddlmZddlmZmZddlm Z m Z ddgZ Gdd„de eƒZ Gd d„de eƒZ d S) é)Úcli)Ú exceptions)Úutils)Ú RESTManagerÚ RESTObject)Ú RefreshMixinÚ RetrieveMixinÚ ProjectJobÚProjectJobManagerc@s eZdZejdƒejejƒdd„ƒƒZejdƒejej ƒdd„ƒƒZ ejdƒejej ƒdd„ƒƒZ ejdƒejej ƒdd„ƒƒZejdƒejejƒd d „ƒƒZejdƒejejƒd d „ƒƒZejdƒejejƒddd„ƒƒZejdƒejejƒddd„ƒƒZejdƒejejƒddd„ƒƒZdS)r cKs"d|jj|jƒf}|jjj|ƒS)a Cancel the job. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobCancelError: If the job could not be canceled z %s/%s/cancel)ÚmanagerÚpathÚget_idÚgitlabÚ http_post)ÚselfÚkwargsr ©rúU/home/ec2-user/environment/venv/lib/python3.6/dist-packages/gitlab/v4/objects/jobs.pyÚcancels zProjectJob.cancelcKs"d|jj|jƒf}|jjj|ƒS)aRetry the job. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobRetryError: If the job could not be retried z %s/%s/retry)r r r rr)rrr rrrÚretrys zProjectJob.retrycKs&d|jj|jƒf}|jjj|ƒdS)aTrigger a job explicitly. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobPlayError: If the job could not be triggered z %s/%s/playN)r r r rr)rrr rrrÚplay,s zProjectJob.playcKs&d|jj|jƒf}|jjj|ƒdS)a&Erase the job (remove job artifacts and trace). Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabJobEraseError: If the job could not be erased z %s/%s/eraseN)r r r rr)rrr rrrÚerase;s zProjectJob.erasecKs&d|jj|jƒf}|jjj|ƒdS)a8Prevent artifacts from being deleted when expiration is set. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the request could not be performed z%s/%s/artifacts/keepN)r r r rr)rrr rrrÚkeep_artifactsJs zProjectJob.keep_artifactscKs&d|jj|jƒf}|jjj|ƒdS)aDelete artifacts of a job. Args: **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabDeleteError: If the request could not be performed z%s/%s/artifactsN)r r r rZ http_delete)rrr rrrÚdelete_artifactsYs zProjectJob.delete_artifactsFNécKs@d|jj|jƒf}|jjj|f|ddœ|—Ž}tj||||ƒS)aªGet the job artifacts. Args: streamed (bool): If True the data will be processed by chunks of `chunk_size` and each chunk is passed to `action` for treatment action (callable): Callable responsible of dealing with chunk of data chunk_size (int): Size of each chunk **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the artifacts could not be retrieved Returns: str: The artifacts if `streamed` is False, None otherwise. z%s/%s/artifactsT)ÚstreamedÚraw)r r r rÚhttp_getrÚresponse_content)rrÚactionÚ chunk_sizerr ÚresultrrrÚ artifactshszProjectJob.artifactscKsBd|jj|jƒ|f}|jjj|f|ddœ|—Ž}tj||||ƒS)aGet a single artifact file from within the job's artifacts archive. Args: path (str): Path of the artifact streamed (bool): If True the data will be processed by chunks of `chunk_size` and each chunk is passed to `action` for treatment action (callable): Callable responsible of dealing with chunk of data chunk_size (int): Size of each chunk **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the artifacts could not be retrieved Returns: str: The artifacts if `streamed` is False, None otherwise. z%s/%s/artifacts/%sT)rr)r r r rrrr)rr rrr rr!rrrÚartifactƒszProjectJob.artifactcKs@d|jj|jƒf}|jjj|f|ddœ|—Ž}tj||||ƒS)azGet the job trace. Args: streamed (bool): If True the data will be processed by chunks of `chunk_size` and each chunk is passed to `action` for treatment action (callable): Callable responsible of dealing with chunk of data chunk_size (int): Size of each chunk **kwargs: Extra options to send to the server (e.g. sudo) Raises: GitlabAuthenticationError: If authentication is not correct GitlabGetError: If the artifacts could not be retrieved Returns: str: The trace z %s/%s/traceT)rr)r r r rrrr)rrrr rr r!rrrÚtraceŸszProjectJob.trace)FNr)FNr)FNr)Ú__name__Ú __module__Ú __qualname__rZregister_custom_actionÚexcZ on_http_errorZGitlabJobCancelErrorrZGitlabJobRetryErrorrZGitlabJobPlayErrorrZGitlabJobEraseErrorrZGitlabCreateErrorrrZGitlabGetErrorr"r#r$rrrrr s*   c@seZdZdZeZddiZdS)r z/projects/%(project_id)s/jobsZ project_idÚidN)r%r&r'Ú_pathr Z_obj_clsZ_from_parent_attrsrrrrr »sN)rrrr(rZ gitlab.baserrZ gitlab.mixinsrrÚ__all__r r rrrrÚs   /