-
Notifications
You must be signed in to change notification settings - Fork 45
8. How to write a script
corey.mac edited this page Nov 9, 2024
·
7 revisions
When adding a script in Seer, it will read the variable SCRIPT_INFO
first, and try to run the function script_info()
if SCRIPT_INFO
does not exist. It fails if neither exists or returns a dictionary type.
-
Required key: name, type, extensions, arguments
-
type
has three values to choose from- 0 : Preview
- 1 : Controls
- 2 : Property
-
extensions
is a list of suffixes, list type, use${type_folder}
when you need to match folders -
arguments
are command line parameters, excludingpython.exe
andpy
file nameSCRIPT_INFO = { "name": "unzip", "type": 1, "extensions": ["zip", "rar", "7z"], "arguments": ["-e", "${7z}", "-i", "${input_file}", "-o", __save_path, "-w"], # optional below "author": "Corey", "version": "1.0.1", "description": "unzip archive file here", # Controls only "icon_path": "icon.png", }
-
- Preview
- Embedded type, OIT: The script displays a window, loads and parses the file, and sends a message to Seer after success, and Seer embeds the window into its preview window. Example parses
ipynb
type tohtml
and displays using built-in browser. - Conversion type: load and parse the input file, and then save it as Seer's internal support type (such as PDF/image/HTML). The example converts an input file to HTML.
- Embedded type, OIT: The script displays a window, loads and parses the file, and sends a message to Seer after success, and Seer embeds the window into its preview window. Example parses
- Controls
- After the preview is loaded successfully, Seer will display a button representing this function on the left side of the control bar, and the specified script will be executed after clicking. The example compresses the folder being previewed into a zip file and saves it to the current folder.
- Property
- After the preview is successful, Seer will automatically call it. The script parses the input file, it saves the data to be displayed in the form of a json file to the specified location, and Seer reads the json file for display. Example for computing sha512 hashes of exe and dll files.
These will be replaced with real value, and sent to the script as arguments.
-
${7z}
the absolute path of 7z.exe which is distributed with SeerC:/Program Files (x86)/Seer/plugins/7z.exe
-
${seer_exe}
the absolute path of Seer.exeC:/Program Files (x86)/Seer/Seer.exe
-
${seer_dir}
where Seer.exe is locatedC:/Program Files (x86)/Seer/
-
${input_file}
the target file path, could be a file or a folder/file/to/the_preview_file
-
${output_file}
the location for output file: temp*folder + randomfilename***_without_extension**- when it's for Property, this value is needed
- when it's for Preview, this value is needed when using script convert the unknown file format to a builtin format
/path/to/temp_folder/random_str
-
${oit}
- Preview- used to tell Seer that it's using the embedded widget to preview
- a flag for Seer, and will not be passed to the script as a command line argument
- embed a foreign window into Seer: used in ipynb
-
${no_cache}
- Preview- used to tell Seer to delete the temporary files after the preview is closed
- a flag for Seer, and will not be passed to the script as a command line argument
-
${type_folder}
- Controls only, for now- used to match folder type since it doesn't have a extension
-
${use_backslash}
use \ instead of /