Documentation for the main executable file (DDRescue_GUI.py)¶
This is the main script that you use to start DDRescue-GUI.
- class ddrescue_gui.DDRescue_GUI.BackendThread(parent)[source]¶
Handles getting input from ddrescue during a recovery, and forwards it back to the GUI thread as required.
- class ddrescue_gui.DDRescue_GUI.CustomTextCtrl(parent, wx_id, value, style)[source]¶
A custom wx.TextCtrl that provides features that are broken on Linux and Cygwin.
- Features:
A version of XYToPosition() that fixes a bug on Linux and Cygwin. carriage_return(): Handles carriage returns correctly. up_one_line(): Moves insertion point up one line.
- XYToPosition(column, row)[source]¶
A custom version of wx.TextCtrl.XYToPosition() that fixes a bug on Linux and Cygwin.
- Args:
- column (int). The column we want to get the integer
position for.
- row (int). The row we want to get the integer
position for.
- Returns:
int. The position.
Note
This is required on Linux/Cygwin because the built-in one has a quirk: when you’re at the end of the text, it always returns -1.
- add_line(data, crs, uols, char_number)[source]¶
Adds a new line to the custom output box. Also handles calling carriage_return() and up_one_line() when required. Receives the data chunks and other information from the update method.
- Args:
- data (string). The chunk of text to add to the
output box.
- crs (list). A list of character numbers where
the character is a carriage return.
- uols (list). As above, for up-one-line
sequences.
- char_number (int). The character number we are at in
the line (the character after the last character in our chunk of text).
- carriage_return()[source]¶
Handles carriage returns in output. This is done by going back to the last newline in the box - any new text will now overwrite what is there.
- class ddrescue_gui.DDRescue_GUI.DiskInfoWindow(parent)[source]¶
DDRescue-GUI’s disk information window.
- get_diskinfo(event=None)[source]¶
Call the thread to get Disk info, disable the refresh button, and start the throbber
- class ddrescue_gui.DDRescue_GUI.ElapsedTimeThread(parent)[source]¶
Keeps track of elapsed time during a recovery. A separate thread is used for this because wx.Timer wasn’t working on macOS, and the BackendThread blocks if ddrescue pauses.
- class ddrescue_gui.DDRescue_GUI.FinishedWindow(parent, disk_capacity, recovered_data)[source]¶
This is displayed after a recovery is finished/aborted. Used to provide the user w/ options to restart the GUI, mount the output file, or close the GUI.
- on_mount(event=None)[source]¶
Triggered when mount button is pressed, used to initiate mounting the output file/device.
- class ddrescue_gui.DDRescue_GUI.GetDiskInformation(parent)[source]¶
Used to get disk information without blocking the GUI thread. Calls parent.receive_diskinfo when info has ben retrieved.
- class ddrescue_gui.DDRescue_GUI.MainWindow[source]¶
DDRescue-GUI’s main window.
- check_for_updates(event=None, starting_up=False)[source]¶
Check for updates using the plist-formatted update file on my website. If on startup, only display info to the user if there was an update. Otherwise (aka requested by user), always display the information.
- Args:
- starting_up[=True] (boolean). If the GUI is starting up, specify
True, otherwise leave unspecified.
Create the menus
- file_choice_handler(_type, user_selection, default_dir, wildcard, style)[source]¶
Handle file dialogs for set_input_file, set_output_file, and set_map_file.
- Args:
- _type (string). The type of file we’re handling. “Input”,
“Output”, or “Map”.
- user_selection (string): The option the user selected in the
choice box.
- default_dir (string): The default directory any file dialogs
are to use.
- wildcard (string): The wildcard that any file dialogs
are to use.
- style (int): The style that any file dialogs are
to use.
- focus_on_control_button(event=None)[source]¶
Focus on the control button instead of the TextCtrl, and reset the insertion point back after 30 milliseconds, preventing the user from changing the insertion point and messing the formatting up.
- get_confirm_text()[source]¶
Generate recovery confirmation text to make doubly sure the right devices are selected. This can be logged and put in a message dialog.
- Returns:
String. The confirmation text.
- get_diskinfo(event=None)[source]¶
Call the thread to get Disk info, disable the update button, and start the throbber
- handle_no_mapfile(key, choice_box)[source]¶
Handles when the user selects not to have a mapfile.
- Args:
key (string): The unique key used to identify the output file. choice_box (wx.Choice): The output choice box.
- handle_outputfile_special_cases(key, choice_box)[source]¶
Handles special cases for the output choice box.
- Args:
key (string): The unique key used to identify the output file. choice_box (wx.Choice): The output choice box.
- handle_user_file_selection(_type, key, user_selection, paths, choice_box)[source]¶
Handles user file selection for the main settings choiceboxes.
- Args:
_type (string): The type of file we’re setting (Input, Output, or Map). key (string): The unique key used to identify the output file. user_selection (string): The user’s selected path/file. paths (dict): The custom paths defined for this type of file. choice_box (wx.Choice): The output choice box.
- on_control_button(event=None)[source]¶
Handle events from the control button, as its purpose changes during and after recovery. Call self.on_abort() when clicked during a recovery. Call self.on_start() otherwise.
- on_detailed_info(event=None)[source]¶
Show/Hide the detailed info, and rotate the arrow next to the text label.
- on_exit(event=None, just_finished_recovery=False)[source]¶
Exit DDRescue-GUI, if certain conditions are met (for example we aren’t in the middle of a recovery). Also offer to save the log file for debugging / error-reporting purposes.
- Args:
- just_finished_recovery (bool).
- True - Display FinishedWindow if user cancels
the exit attempt.
- False - The default, do nothing if user cancels
the exit attempt.
- on_mount(event=None)[source]¶
When the user asks to mount a file, handle this and show FinishedWindow in order to carry out the request.
- on_recovery_ended(result, disk_capacity, recovered_data, return_code=None)[source]¶
Called by the backend thread to show FinishedWindow and update the main window when a recovery is completed or aborted by the user, or when a recovery errors out for some reason.
- Args:
- result (string). The reason why the recovery ended. Used to
let the user know what is happening. Values are “NoInitialStatus”, “BadReturnCode”, and “Success”.
disk_capacity (string). The capacity of the input file or disk. recovered_data (string). The amount of data we recovered.
- return_code[=None] (int). GNU ddrescue’s return code. Useful if
the recovery failed for some reason.
- on_start()[source]¶
Check the settings, prepare to start ddrescue, unmount the input file if needed, and start the backend thread.
- on_terminal_output(event=None)[source]¶
Show/Hide the terminal output, and rotate the arrow next to the text label.
- prompt_to_kill_ddrescue()[source]¶
Prompts the user to try killing ddrescue again if it’s not exiting. This sometimes happens if the system is overloaded, or if a disk is taking a very long time to timeout/fail a read operation.
- receive_diskinfo(info)[source]¶
Get new Disk info, stop the throbber and call the function that updates the choiceboxes for input and output file selection.
- restart()[source]¶
Restart and reset MainWindow, so MainWindow is as it was when DDRescue-GUI was started.
- set_map_file(event=None)[source]¶
Get the map file position/name by calling self.file_choice_handler.
- set_progress_bar_range(_range)[source]¶
Set the progress bar’s range.
- Args:
_range (int). The range to set the progress bar to use.
- show_settings(event=None)[source]¶
Show the settings Window, but only if input and output files have already been selected.
- update_average_read_rate(average_read_rate)[source]¶
Update the average read rate info.
- Args:
average_read_rate (string). The average read rate.
- update_current_read_rate(current_read_rate)[source]¶
Update the current read rate info.
- Args:
current_rate_rate (string). The current read rate.
- update_error_size(error_size)[source]¶
Update the error size info.
- Args:
error_size (string). The amount of unreadable data so far.
- update_input_pos(input_pos)[source]¶
Update the input position info.
- Args:
- input_pos (string). The current position in the input file
or device.
- update_num_errors(num_errors)[source]¶
Update the num errors info.
- Args:
num_errors (string). The number of read errors so far.
- update_output_pos(output_pos)[source]¶
Update the output position info.
- Args:
- output_pos (string). The current position in the output file
or device.
- update_progress(recovered_data, disk_capacity)[source]¶
Update the progress bar and the title. Do nothing if disk capacity is unknown.
- Args:
- recovered_data (int). The amount of data currently recovered
(units vary based on disk size).
- disk_capacity (int). The capacity (or size) of the input
file or disk.
- update_recovered_data(recovered_data)[source]¶
Update the recovered data info.
- Args:
recovered_data (string). The amount of data recovered so far.
- update_status_bar(message)[source]¶
Update the status bar with a new message.
- Args:
message (string). The message to set the status bar to.
- update_time_elapsed(time_elapsed)[source]¶
Update the time elapsed text.
- Args:
- time_elapsed (string). The label to use for the time elapsed
text.
- class ddrescue_gui.DDRescue_GUI.MyApp(redirect=False, filename=None, useBestVisual=False, clearSigInt=True)[source]¶
The wxPython app. Must be declared for application to work. This is how the application is started.
- class ddrescue_gui.DDRescue_GUI.PrivPolWindow(parent)[source]¶
DDRescue-GUI’s privacy policy window.
- class ddrescue_gui.DDRescue_GUI.SettingsWindow(parent)[source]¶
DDRescue-GUI’s settings window
- create_check_boxes()[source]¶
Create all CheckBoxes for SettingsWindow, and set their default states (all unchecked)
- create_choice_boxes()[source]¶
Create all ChoiceBoxes for SettingsWindow, and call self.set_default_recovery_settings()
- set_best_recovery_settings(event=None)[source]¶
Set selections for the Choiceboxes to best recovery settings.
- set_default_recovery_settings(event=None)[source]¶
Set selections for the Choiceboxes to default settings.
- set_fast_recovery_settings(event=None)[source]¶
Set selections for the Choiceboxes to fast recovery settings.