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
 Connect to the remote repository and check for updates.
 
virtual void connect (const std::string &webserverurl="")=0
 Allow the ScriptRepository to double-check the connection with the web server.
 
virtual const std::string & description (const std::string &path)=0
 Provide the description of the file at the given path.
 
virtual void download (const std::string &file_path)=0
 Create a copy of the remote file/folder inside the local repository.
 
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.
 
virtual std::string ignorePatterns ()=0
 Return the ignore patterns that were defined through ScriptRepository::setIgnorePatterns.
 
virtual ScriptInfo info (const std::string &path)=0
 Return information about the script through the Mantid::API::ScriptInfo struct.
 
virtual void install (const std::string &local_path)=0
 Install, at the given local_path, the resources that allow the ScriptRepository to operate locally.
 
virtual bool isValid ()=0
 Check whether the local repository exists.
 
virtual std::vector< std::string > listFiles ()=0
 Return the list of files inside the repository.
 
virtual int setAutoUpdate (const std::string &path, bool option=true)=0
 Define the AutoUpdate option, which determines whether a file is updated as soon as new versions are available in the central repository.
 
virtual void setIgnorePatterns (const std::string &patterns)=0
 Define the file patterns that will not be listed by listFiles.
 
virtual ~ScriptRepository ()=default
 Virtual destructor (always needed for abstract classes)
 

Detailed Description

Definition at line 267 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

Connect to the remote repository and check for updates.

This method needs to know the remote URL, which must be available to the object before check4Update is called.

It checks the state of the central repository and downloads all the files marked as AutoUpdate.

Attention
Executing this method periodically is not the responsibility of the ScriptRepository itself. The other methods may not respond properly if this method is not executed.
Note
This operation requires an internet connection.
Exceptions
ScriptRepoExceptionmainly reports a connection failure, but may also report that the local repository could not be created.
Returns
List of all the files that were automatically downloaded.

Referenced by Mantid::Algorithms::UpdateScriptRepository::exec(), and 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.

The webserverurl argument is optional; if omitted, it is taken from the settings defined for the ScriptRepository.

This method ensures that the network and the link are 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 at the given path.

Parameters
pathscript path relative to the repository, or to the operating 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 a folder, it copies all the files inside the folder as well.

If a file is reported to have local changes (

See also
ScriptRepository::fileStatus), the download will overwrite it with a copy of the remote file, but will keep a backup of the local file. This is reported by throwing an exception.

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

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

Referenced by export_ScriptRepository().

◆ fileInfo()

ScriptInfo Mantid::API::ScriptRepository::fileInfo ( const std::string &  path)
inline
Deprecated:
Old name for info(); kept for compatibility and to be removed.

Definition at line 301 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 patterns that were defined through ScriptRepository::setIgnorePatterns.

◆ info()

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

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

It may throw an exception if the file is present neither locally nor remotely.

Parameters
path: script path relative to the repository, or to the operating 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 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, at the given local_path, the resources that allow the ScriptRepository to operate locally.

It may create any hidden files needed for the operation of this class.

At the end, a new folder is created at local_path (if it does not already exist).

Parameters
local_pathpath at which the folder will be created.
Exceptions
ScriptRepoExceptionif local_path cannot be created (for example, because of permission issues).

Referenced by export_ScriptRepository().

◆ isValid()

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

Check whether the local repository exists.

If there is no local repository (it was never installed), isValid returns false and the only valid method 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 and folders that are inside the local repository as well as remotely.

Note
The path uses 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, ScriptRepository::install must be run (at least once).

◆ setAutoUpdate()

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

Define the AutoUpdate option, which determines whether a file is updated as soon as new versions are available in the central repository.

This information is kept in a property system so that it is available afterwards.

Parameters
path: file or folder inside the local repository.
optionauto-update flag. If true, new versions of the path will replace the local file as soon as they are available in the central repository.
Returns
int: number of files changed (folders cascade to their contents).
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 by listFiles.

This lets the ScriptRepository avoid listing hidden files, automatically generated files and so on, giving the user a cleaner view of the repository.

For example, pyc files are automatically generated and should be discarded. You could also ignore files ending with ~, which are temporary files on linux. The patterns are evaluated as csv regex patterns.

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

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

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

These settings must be preserved and remain available afterwards through the configuration system.


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