plowshare package

Submodules

plowshare.hosts module

plowshare.plowshare module

class plowshare.plowshare.Plowshare(host_list=['euroshare_eu', 'ge_tt', 'gfile_ru', 'multiupload', 'rghost', 'zalil_ru'])[source]

Bases: object

Upload and download files using the plowshare tool.

download(sources, output_directory, filename)[source]

Download a file from one of the provided sources

The sources will be ordered by least amount of errors, so most successful hosts will be tried first. In case of failure, the next source will be attempted, until the first successful download is completed or all sources have been depleted.

Parameters:
  • sources (list) – A list of dicts with ‘host_name’ and ‘url’ keys.
  • output_directory (str) – Directory to save the downloaded file in.
  • filename (str) – Filename assigned to the downloaded file.
Returns:

A dict with ‘host_name’ and ‘filename’ keys if the download is successful, or an empty dict otherwise.

Return type:

dict

download_from_host(source, output_directory, filename)[source]

Download a file from a given host.

This method renames the file to the given string.

Parameters:
  • source (dict) – Dictionary containing information about host.
  • output_directory (str) – Directory to place output in.
  • filename (str) – The filename to rename to.
Returns:

Dictionary with information about downloaded file.

Return type:

dict

multiupload(filename, hosts)[source]

Upload file to multiple hosts simultaneously

The upload will be attempted for each host until the optimal file redundancy is achieved (a percentage of successful uploads) or the host list is depleted.

Parameters:
  • filename (str) – The filename of the file to upload.
  • hosts (list) – A list of hosts as defined in the master host list.
Returns:

A list of dicts with ‘host_name’ and ‘url’ keys for all successful uploads or an empty list if all uploads failed.

Return type:

list

parse_output(hostname, output)[source]

Parse plowup’s output.

For now, we just return the last line.

Parameters:
  • hostname (str) – Name of host you are working with.
  • output (dict) – Dictionary containing information about a plowshare action.
Returns:

Parsed and decoded output list.

Return type:

list

random_hosts(number_of_hosts)[source]

Retrieve a random subset of available hosts.

The number of hosts provided must not be larger than the number of available of hosts, otherwise it will throw a ValueError exception.

Parameters:number_of_hosts (int) – Number of hosts to connect to.
Returns:Random subsample of available hosts.
Return type:list
Raises:ValueError
upload(filename, number_of_hosts)[source]

Upload the given file to the specified number of hosts.

Parameters:
  • filename (str) – The filename of the file to upload.
  • number_of_hosts (int) – The number of hosts to connect to.
Returns:

A list of dicts with ‘host_name’ and ‘url’ keys for all successful uploads or an empty list if all uploads failed.

Return type:

list

upload_to_host(filename, hostname)[source]

Upload a file to the given host.

This method relies on ‘plowup’ being installed on the system. If it succeeds, this method returns a dictionary with the host name, and the final URL. Otherwise, it returns a dictionary with the host name and an error flag.

Parameters:
  • filename (str) – The filename of the file to upload.
  • hostname (str) – The host you are uploading the file to.
Returns:

Dictionary containing information about upload to host.

Return type:

dict

plowshare.settings module

Module contents

Table Of Contents

This Page