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: |
|
---|---|
Returns: | the job id given to the job |
Return type: | int or None if can’t |
Raises: |
|
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: |
|
---|---|
Returns: | taskspooler server command line |
Return type: |
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 |
GalaxieDrake.utils.
Utils
[source]¶Bases: object
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: |
---|
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 |
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_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 |
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 |
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 |
---|
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 |