Mantid
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Mantid::API::ScriptRepository Class Referenceabstract

#include <ScriptRepository.h>

Public Member Functions

virtual std::vector< std::string > check4Update ()=0
 Connects to the remote repository checking for updates. More...
 
virtual void connect (const std::string &webserverurl="")=0
 Allow the ScriptRepository to double check the connection with the web server. More...
 
virtual const std::string & description (const std::string &path)=0
 Provide the description of the file given the path. More...
 
virtual void download (const std::string &file_path)=0
 Create a copy of the remote file/folder inside the local repository. More...
 
ScriptInfo fileInfo (const std::string &path)
 
virtual SCRIPTSTATUS fileStatus (const std::string &file_path)=0
 Return the status of the file, according to the status defined in Mantid::API::SCRIPTSTATUS. More...
 
virtual std::string ignorePatterns ()=0
 Return the ignore patters that was defined through ScriptRepository::setIgnorePatterns. More...
 
virtual ScriptInfo info (const std::string &path)=0
 Return the information about the script through the Mantid::API::ScriptInfo struct. More...
 
virtual void install (const std::string &local_path)=0
 Install the necessary resources at the local_path given that allows the ScriptRepository to operate locally. More...
 
virtual bool isValid ()=0
 Check if the local repository exists. More...
 
virtual std::vector< std::string > listFiles ()=0
 Return the list of files inside the repository. More...
 
virtual void remove (const std::string &file_path, const std::string &comment, const std::string &author, const std::string &email)=0
 Delete the file from the remote repository (it does not touch the local copy). More...
 
virtual int setAutoUpdate (const std::string &path, bool option=true)=0
 Define the AutoUpdate option, which define if a file will be updated as soon as new versions are available at the central repository. More...
 
virtual void setIgnorePatterns (const std::string &patterns)=0
 Define the file patterns that will not be listed in listFiles. More...
 
virtual void upload (const std::string &file_path, const std::string &comment, const std::string &author, const std::string &email)=0
 Upload the local file/folder to be available at the remote repository. More...
 
virtual ~ScriptRepository ()=default
 Virtual destructor (always needed for abstract classes) More...
 

Detailed Description

Definition at line 291 of file ScriptRepository.h.

Constructor & Destructor Documentation

◆ ~ScriptRepository()

virtual Mantid::API::ScriptRepository::~ScriptRepository ( )
virtualdefault

Virtual destructor (always needed for abstract classes)

Member Function Documentation

◆ check4Update()

virtual std::vector< std::string > Mantid::API::ScriptRepository::check4Update ( )
pure virtual

Connects to the remote repository checking for updates.

This method, needs to know the remote URL wich must be available to the object before calling the check4update.

It must check the state of the central repository and download all the files marked as AutoUpdate.

Attention
The responsibility of executing this method periodically, is not of the ScriptRepository it self. The others methods may not respond propperly, if this method is not executed.
Note
This operation requires internet connection.
Exceptions
ScriptRepoExceptionnotifies mainly connection failure, but, may eventually, notify that the local repository may not be created.
Returns
List with all the files automatically downloaded.

Referenced by export_ScriptRepository().

◆ connect()

virtual void Mantid::API::ScriptRepository::connect ( const std::string &  webserverurl = "")
pure virtual

Allow the ScriptRepository to double check the connection with the web server.

An optional argument is allowed webserverurl, but, it may be taken from the settings defined for the ScriptRepository.

This method ensures that the network and the link is available.

Parameters
webserverurl: url of the mantid web server.
Exceptions
ScriptRepoExceptionFailure to connect to the web server and the reason why.

◆ description()

virtual const std::string & Mantid::API::ScriptRepository::description ( const std::string &  path)
pure virtual

Provide the description of the file given the path.

Parameters
pathScript path related to the reposititory, or the operative system.
Returns
the description of the file or folder.

◆ download()

virtual void Mantid::API::ScriptRepository::download ( const std::string &  file_path)
pure virtual

Create a copy of the remote file/folder inside the local repository.

For folder, it will copy all the files inside the folder as well.

If one file is reported to have local changes (

See also
ScriptRepository::fileStatus) the download will make a copy of the remote file, but will preserve a backup of the local file. This incident will be reported through throwing an exception.

For folders, the exception will also list all the files that a backup was created.

Parameters
file_pathof a file or folder to be downloaded.
Exceptions
ScriptRepoExceptionto indicate file is not available at remotely or to indicate that a conflict was found.

Referenced by export_ScriptRepository().

◆ fileInfo()

ScriptInfo Mantid::API::ScriptRepository::fileInfo ( const std::string &  path)
inline
Deprecated:
Previous version, to be removed.

Definition at line 324 of file ScriptRepository.h.

◆ fileStatus()

virtual SCRIPTSTATUS Mantid::API::ScriptRepository::fileStatus ( const std::string &  file_path)
pure virtual

Return the status of the file, according to the status defined in Mantid::API::SCRIPTSTATUS.

Parameters
file_pathfor file/folder
Returns
SCRIPTSTATUS : of the given file/folder
Exceptions
ScriptRepoExceptionto indicate that file is not available.

◆ ignorePatterns()

virtual std::string Mantid::API::ScriptRepository::ignorePatterns ( )
pure virtual

Return the ignore patters that was defined through ScriptRepository::setIgnorePatterns.

◆ info()

virtual ScriptInfo Mantid::API::ScriptRepository::info ( const std::string &  path)
pure virtual

Return the information about the script through the Mantid::API::ScriptInfo struct.

It may throw exception if the file is not presented locally, or even remotelly.

Parameters
path: Script path related to the repository, or to operate system.
Returns
Mantid::API::ScriptInfo : Information about the script.
Exceptions
ScriptRepoExceptionMainly for scripts not found.
ScriptSharing spt;
ScriptInfo info = spt.info("README.md");
// info.author : returns the file author.
virtual ScriptInfo info(const std::string &path)=0
Return the information about the script through the Mantid::API::ScriptInfo struct.
Information about the files inside the repository.

◆ install()

virtual void Mantid::API::ScriptRepository::install ( const std::string &  local_path)
pure virtual

Install the necessary resources at the local_path given that allows the ScriptRepository to operate locally.

It is allowed to create hidden files that would be necessary for the operation of this class.

At the end, a new folder is created (if it does not exists already), with the given local_path given.

Parameters
local_pathpath where the folder (having the same name given) will be created.
Exceptions
ScriptRepoExceptionIf the local_path may not be created (Permission issues).

Referenced by export_ScriptRepository().

◆ isValid()

virtual bool Mantid::API::ScriptRepository::isValid ( )
pure virtual

Check if the local repository exists.

If there is no local repository, the repository was never installed, the isValid will return false, and the only method valid is ScriptRepository::install.

◆ listFiles()

virtual std::vector< std::string > Mantid::API::ScriptRepository::listFiles ( )
pure virtual

Return the list of files inside the repository.

It provides a file-system like path for all the files, folders that are inside the local repository as well as remotely.

Note
The path used a normal slash to separate folders.

Consider the following repository:

README.md
folderA
folderA/fileB
fileC

And the local repository folder containing these files:

README.md
NewFile

List files, must show all the files:

README.md
folderA
folderA/fileB
fileC
NewFile
Returns
List of all the files available inside the repository as a file system path relative to the local repository.
Exceptions
Maythrow Invalid Repository if the local repository was not generated. In this case, it is necessary to execute the ScriptRepository::install (at least once).

◆ remove()

virtual void Mantid::API::ScriptRepository::remove ( const std::string &  file_path,
const std::string &  comment,
const std::string &  author,
const std::string &  email 
)
pure virtual

Delete the file from the remote repository (it does not touch the local copy).

After this, the file will not be available for anyone among the users. As so, it is required a justification of why to remove (the comment), and the current rule accept that only the owner of the file (which is considered the last one to use the file) is allowed to remove it.

The file will be removed from the central repository (git)

Note
This operation requires internet connection.
Parameters
file_pathfor the file to be deleted. It will not accept deleting folders for security reason.
commentThe reson of why deleting this entry.
authorAn string that may identify who is requesting to delete the file. It accept only the last author to remove it.
emailAn string that identifies the email of the author.
Exceptions
ScriptRepoExceptionmay be triggered for an attempt to delete folders, or a non existent file, or not allowed operation, or any network erros.

◆ setAutoUpdate()

virtual int Mantid::API::ScriptRepository::setAutoUpdate ( const std::string &  path,
bool  option = true 
)
pure virtual

Define the AutoUpdate option, which define if a file will be updated as soon as new versions are available at the central repository.

This information will be kept in a property system, in order to be available afterwards.

Parameters
path: file or folder inside the local repository
optionflag to set for auto-update, or not. If true, new versions of the path will replace the local file as soon as they are available at the central repository.
Returns
int: number of files changed (because of the cascading of folders)
Exceptions
ScriptRepoException: Invalid entry.

◆ setIgnorePatterns()

virtual void Mantid::API::ScriptRepository::setIgnorePatterns ( const std::string &  patterns)
pure virtual

Define the file patterns that will not be listed in listFiles.

This is important to force the ScriptRepository to not list hidden files, automatic generated files and so on. This helps to present to the user a clean presentation of the Repository

For example, there are the pyc files that are automatically generated, and should be discarded. We could set also to ignore files that end with ~, temporary files in linux. The patterns will be evaluated as a csv regex patterns.

To discard all pyc files, set: "*pyc".

To discard all pyc files and hidden files and folders: "*pyc;\b\.*"

Parameters
patterns: csv regex patterns to be ignored when listing files.

This settings must be preserved, and be available after trough the configure system.

◆ upload()

virtual void Mantid::API::ScriptRepository::upload ( const std::string &  file_path,
const std::string &  comment,
const std::string &  author,
const std::string &  email 
)
pure virtual

Upload the local file/folder to be available at the remote repository.

After this, this file/folder will be available for every, being published as with the same license as the mantid framework itself.

The user is not allowed to upload files that are marked as BOTH_CHANGED. It must first download the file (wich will make a copy of the local one), than update the downloaded file with the user own changes. At this point, he may published his file.

Note
This operation requires internet connection.
Parameters
file_pathfor the file/folder to be published. For folders, it will publish all the files inside the folder. (Empty folders will not be accepted).
commentAllows to give information of the last changes, updates on a given file/folder. It differs from description, in the sense, that it may inform just what changed from the last version, while, the description must provide information about the scope of the file.
authorAn string that may identify who is the responsible for changing that file. It may be a nick name, or an e-mail, or even a code, but, it it necessary that it identifies who was responsible for changing the file.
emailAn string that identifies the email of the author.
Exceptions
ScriptRepoExceptionmay be triggered for an attempt to publish an empty folder, a file not present locally, because the file, or one of the files inside the folder are marked as BOTH_CHANGED, or even failure to connect to the remote repository.

The documentation for this class was generated from the following file: