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 macOS.
- Features:
- A version of PositionToXY() that works on macOS. A version of XYToPosition() that works on macOS and fixes a bug on Linux. carriage_return(): Handles carriage returns correctly. up_one_line(): Moves insertion point up one line.
-
PositionToXY(insertion_point)[source]¶ A custom version of wx.TextCtrl.PositionToXY() that works on OS X (the built-in one isn’t implemented on OS X).
- Args:
- insertion_point (int). The insertion point we want to get
- the row and column numbers for.
- Returns:
tuple(int, int).
1st element: The column. 2nd element: The row.
Note
The stock version of this method is still not implemented on OS X on wxPython 4 (it returns random numbers).
-
XYToPosition(column, row)[source]¶ A custom version of wx.TextCtrl.XYToPosition() that works on OS X (the built-in one isn’t implemented on OS X).
- 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 also helpful for Linux because the built-in one has a quirk: when you’re at the end of the text, it always returns -1.
Note
As of wxPython 4, this is still not implemented on macOS.
-
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.
Create all buttons for FinishedWindow.
-
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 some startup, only display info to the user if there was an update. Otherwise (aka requested by user), always display the information.
- Kwargs:
- starting_up[=True] (boolean). If the GUI is starting up, specify
- True, otherwise leave unspecified.
Create all buttons for MainWindow
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 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_diskinfo(event=None)[source]¶ Call the thread to get Disk info, disable the update button, and start the throbber
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.
- Kwargs:
- 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.
- Kwargs:
- 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.
- 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(messeage)[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 all buttons for SettingsWindow
-
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.