GalaxieDrake package

Submodules

GalaxieDrake.prepare module

GalaxieDrake.subripper module

GalaxieDrake.taskspooler module

class GalaxieDrake.taskspooler.TaskSpooler[source]

Bases: object

Try to implement the original taskspooler capability with Python. It’s a pure Binding, where original TaskSpooler is use in background.

add_job(command=None, output=True, stderr=False, gzip=False, fork=True, send_email=False, check_job_before=True, check_job_id=None, label='', slot=1)[source]

Add a job to the taskspooler server, many option are available during the add.

Parameters:
  • command (list) – Command to execute with argument store inside a list
  • output (bool) – Store the output of the command.
  • stderr (bool) – Keep stderr apart, in a name like the output file, but adding ‘.e’.
  • gzip (bool) – Compress the stored output with gzip, without effect if output is False
  • fork (bool) – True for fork precess, False for don’t fork process
  • send_email (bool) – Send the output by e-mail (uses sendmail).
  • check_job_before (bool) – The job will be run only if the job before ends well
  • check_job_id (int or None) – The job will be run only if the job of given id ends well.
  • label (str) – Name the task with a label, to be distinguished on listing.
  • slot (int) – Number of slots required by the job (1 default).
Returns:

the job id given to the job

Return type:

int or None if can’t

Raises:
  • TypeError – When output is not a bool
  • TypeError – When stderr is not a bool
  • TypeError – When gzip is not a bool
  • TypeError – When fork is not a bool
  • TypeError – When send_email is not a bool
  • TypeError – When check_job_before is not a bool
  • TypeError – When check_job_id is not a int or None
  • TypeError – When label is not a str or None
  • TypeError – When slot is not a int
get_add_job_cmd(command=None, output=True, stderr=False, gzip=False, fork=True, send_email=False, check_job_before=False, check_job_id=None, label='', slot=1)[source]

Generate a complex command line, and return it as list.

Parameters:
  • command (list) – Command to execute with argument store inside a list
  • output (bool) – Store the output of the command.
  • stderr (bool) – Keep stderr apart, in a name like the output file, but adding ‘.e’.
  • gzip (bool) – Compress the stored output with gzip, without effect if output is False
  • fork (bool) – True for fork precess, False for don’t fork process
  • send_email (bool) – Send the output by e-mail (uses sendmail).
  • check_job_before (bool) – The job will be run only if the job before ends well
  • check_job_id (int or None) – The job will be run only if the job of given id ends well.
  • label (str) – Name the task with a label, to be distinguished on listing.
  • slot (int) – Number of slots required by the job (1 default).
Returns:

taskspooler server command line

Return type:

list

check_for_taskspooler(app_name='tsp')[source]

Check for is tsp application is available and return it absolute path. If tsp is not found the taskspooler can’t be initialize and raise a error.

Parameters:app_name (str) – The name of taskspooler application, it’s here for permit to test the function
Returns:Absolute path of tsp application or None if not found
Return type:str or None
Raises:SystemError – When tsp can’t be found
get_path()[source]

Return the executable tsp file found in PATH environement variable. Normally TaskSpooler.get() can’t return None that because, TaskSpooler.check_for_taskspooler() have normaly raise a error, during the initialization of the TaskSpooler Class.

Returns:the taskspooler absolute path
Return type:str
kill_the_task_spooler_server()[source]

Implement the capability to kill the task spooler server the TaskSpooler.

It stop every running and queued task’s, without any output.

-K kill the task spooler server
Returns:None
Return type:None
clear_the_list_of_finished_jobs()[source]

Implement the capability to clear finished jobs

-C clear the list of finished jobs

Returns:None
Return type:None
show_the_job_list()[source]

Display the job list, if you want the job list see TaskSpooler.get_jobs_list()

-l show the job list (default action)
Returns:None
get_jobs_list()[source]

Return the jobs list, with python format list. That function don’t return a class attribute value, it request the TaskSpooler server with -l option each time you call it function.

TaskSpooler.show_the_job_list() will use it function for get task list. each item of it list contain a Dictionary with special keynames: ID, State, Output, E-Level, Times, Command

Times key contain a second dictionary level with keynames: r, s, u

Returns:TaskSpooler server job list
Return type:list
get_number_of_simultaneous_jobs()[source]

Return the number of max simultaneous jobs of the server.

-S [num] get/set the number of max simultaneous jobs of the server.

Returns:the actual value
Return type:int or None if can’t get
set_number_of_simultaneous_jobs(simultaneous_jobs=1)[source]

Set the number of max simultaneous jobs of the server.

-S [num] get/set the number of max simultaneous jobs of the server.

Returns:the actual value
get_pid(job=None)[source]

Return the pid number of a job number pass as parameter

Parameters:job (int) – the job number
Returns:pid
Return type:int
get_output_file(job=None)[source]

Return the output file of a job number pass as parameter. If not specified , return the last job run output file.

Parameters:job (int) – the job number
Returns:output file
Return type:str
get_job_information(job=None)[source]

Return the job information of a job number pass as parameter. If not specified , return the last job run information.

Parameters:job (int) – the job number
Returns:information
Return type:list
get_job_state(job=None)[source]

Return the output file of a job number pass as parameter. If not specified , return the last job run output file.

Parameters:job (int) – the job number
Returns:output file
Return type:str
get_version()[source]

GalaxieDrake.transcoder module

GalaxieDrake.utils module

class GalaxieDrake.utils.Utils[source]

Bases: object

static get_title_from_video_file(filename=None)[source]

Return the titles of a movie file, by remove the extension and kodi style naming of definition. The titles consist to the basename of the file and definition naming remove.

By example: “/home/lulu/my_super_video - 1080p.mkv” will return “my_super_video”

Returns:the title of the file or None if filename is None
Return type:str or None
copy_file(src=None, dst=None, enable_progress_bar=True, debug=1)[source]

It function use ‘dd’ for copy file, and have capability to display a progress bar

Parameters:
  • src (str) – Source file to copy , as absolute path
  • dst (str) – Destination file where src will be copy , as absolute path
  • enable_progress_bar (bool) – True for enable to display the progress, or False to disable
static check_if_file_exist(file_to_check=None)[source]

Check if the file exist and is readable, or return False

Returns:True if exist and readable else False
Return type:bool
static cli_progress_bar(label, val, end_val, bar_length)[source]
new_id()[source]

Generate a ID like ‘E59E8457’ , two chars by two chars it’s a random HEX

Default size : 8 Default chars: ‘ABCDEF0123456789’

max_iteration = 10000000 - Take 99.114s on Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz max_iteration = 1000000 - Take 9.920s on Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz max_iteration = 100000 - Take 0.998s on Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz max_iteration = 10000 - Take 0.108s on Intel(R) Core(TM) i7-2860QM CPU @ 2.50GHz

Returns:a string it represent a unique ID
Return type:str
which(program=None)[source]

Return the absolute path of a program or None if not found.

Parameters:program (str) – A program where we want the absolute path
Returns:Absolute path of the program
Return type:str or None
get_mkvmerge_path(mkvmerge_app_name='mkvmerge')[source]

Return absolute path of mkvmerge or None if not found

Parameters:mkvmerge_app_name (str) – in case dd have a other name like mkvmerge-4.2
Returns:absolute path or None
Return type:str or None
get_dd_version()[source]

Get the dd version number

Returns:dd version number
Return type:str
get_dd_path(dd_app_name='dd')[source]

Return absolute path of mkvextract or None if not found

Parameters:dd_app_name (str) – in case dd have a other name like dd-4.2
Returns:absolute path or None
Return type:str or None
get_mkvextract_version()[source]

Get the mkvextract version number

Returns:mkvextract version number
Return type:str
get_mkvextract_path(mkvextract_app_name='mkvextract')[source]

Return absolute path of mkvextract or None if not found

Parameters:mkvextract_app_name (str) – in case mkvextract have a other name like mkvextract-4.2
Returns:absolute path or None
Return type:str or None
get_mediainfo_path(mediainfo_app_name='mediainfo')[source]

Return the absolute path of mediainfo or None if not found

Parameters:mediainfo_app_name (str) – in case mediainfo have a other name like mediainfo-4.2
Returns:absolute path or None
Return type:str or None
get_mediainfo_version()[source]

Get the mediainfo version number

Returns:mediainfo version number
Return type:str
get_nice_path(nice_app_name='nice')[source]

Return absolute path of nice or None if not found

Parameters:nice_app_name (str) – in case nice have a other name live nice-4.2
Returns:absolute path or None
Return type:str or None
get_nice_version()[source]

Get the Nice version number

Returns:Nice version
Return type:str
set_nice_priority(value=15)[source]

Set the nice priority, for be nice with other process. See Utils.get_nice_priority() for get that value.

Transcoding take time then be nice with the system, is not trivial, that permit to use the system for a other task-s See: https://en.wikipedia.org/wiki/Nice_%28Unix%29

Parameters:value (int) – the nice priority
Raises:TypeError – When value is not int
get_nice_priority()[source]

Get nice priority , use for have the transcoder nice with other process, typically for let ressource to a Kodi Media Backed. The default is 15, that a good value, if regarding the time take a transcoding lost 5 seconds and be nice with other process is a good thing.

Returns:The nice value it will be use to the final command send to the taskspooler
Return type:int
static get_subripper_filename()[source]

Get the SubRipper filename ‘subripper.py’

Returns:the filename of subripper script
Return type:str
get_subripper_path()[source]

Get the SubRipper path, suppose to be locate where prepare script is store. Eventually the SubRipper script can be store somewhere else, only if the function will be found it on $PATH env variable.

That function return None if no subripper script is found, Note that function is not in charge to raise error where no SubRipper script is found. See Utils.check_subripper_requirement() for that…

Returns:SubRipper absolute path
Return type:str or None
check_subripper_requirement()[source]

In charge to crash with a error message

Raises:SystemError – when the SubRipper is not found
static get_transcoder_filename()[source]

Get the Transcoder filename ‘transcoder.py’

Returns:the filename of transcoder script
Return type:str
get_transcoder_path()[source]

Get the Transcoder path, suppose to be locate where prepare script is store. Eventually the Transcoder script can be store somewhere else, only if the function will be found it on $PATH env variable.

That function return None if no transcoder script is found, Note that function is not in charge to raise error where no Transcoder script is found. See Utils.check_transcoder_requirement() for that…

Returns:Transcoder absolute path
Return type:str or None
check_transcoder_requirement()[source]

In charge to crash with a error message

Raises:SystemError – when the transcoder is not found

Module contents