Folder system
SweepMe! creates several folders on its first start. The FolderManager resolves the path of each of these folders from a short key string. It is part of the open-source pysweepme package, so the same folders can be queried both inside SweepMe! and from your own Python scripts.
Retrieving a folder path
The most convenient way is the top-level get_path function of pysweepme:
import pysweepme
print(pysweepme.get_path("TEMP")) # path to the temp folder
The same function is available through the FolderManager submodule together with the FolderManager instance that SweepMe! uses internally:
from pysweepme import FolderManager
FoMa = FolderManager.FolderManager() # singleton instance
print(FoMa.get_path("TEMP"))
Each folder is related to a certain key string (see below). get_path returns False and logs a debug message if the key is unknown.
Setting a folder path
A folder can be redirected with set_path, e.g. to load drivers from a custom location:
import pysweepme
pysweepme.set_path("CUSTOMDEVICES", r"C:\MyDrivers")
set_path returns True on success and False if the key is unknown.
Folder key strings
| Key | Folder |
|---|---|
MAIN |
Installation folder of SweepMe!.exe
|
TEMP |
Temporary folder in the local OS user folder |
PUBLIC |
Public SweepMe! folder of the public OS user |
ROAMING |
SweepMe! folder in the roaming folder of the current OS user |
LOCAL |
SweepMe! folder in the local AppData of the current OS user |
PROGRAMDATA |
SweepMe! folder in ProgramData (shared, not easily visible) |
DATA |
Measurement data folder (in PUBLIC) |
SETTINGS |
Settings folder (in PUBLIC) |
EXAMPLES |
Example settings (in MAIN) |
DEVICES |
Drivers shipped with SweepMe! (in MAIN) |
CUSTOMDEVICES |
User drivers (in PUBLIC) |
MODULES |
Modules shipped with SweepMe! (in MAIN) |
CUSTOMMODULES |
User modules (in PUBLIC) |
VERSIONS |
Downloaded driver/module versions (in ProgramData) |
CALIBRATIONS |
Calibration files (in PUBLIC) |
CUSTOM / CUSTOMFILES |
Custom files (in PUBLIC) |
EXTLIBS |
External libraries such as DLLs (in PUBLIC) |
SCREENSHOTS |
Screenshots folder (in PUBLIC) |
Further keys exist (e.g. RESOURCES, PROFILES, CONFIG, SERVER, SHAREDDEVICES, SHAREDMODULES, INTERFACES, WIDGETS, DATADEVICES, DATAMODULES, CUSTOMRESOURCES, CUSTOMICONS, CUSTOMSTYLES, CUSTOMCOLORMAPS, PYTHONSCRIPTS). The authoritative list is the folders dictionary in FolderManager.py of the pysweepme source.
Note: The keys above work properly inside SweepMe!. When used with pysweepme standalone, some keys do not point to a meaningful location, because MAIN is the folder of the running Python script/interpreter rather than a SweepMe! installation. Folders derived from MAIN (e.g. DEVICES, MODULES, EXAMPLES) are therefore only reliable inside SweepMe!.
Adding a driver library folder to the path
Drivers can ship additional libraries (DLLs, wheels, ...) in a libraries or libs subfolder. addFolderToPATH adds these to sys.path and, where DLL files are found, to the environment PATH. When loading a driver with get_driver this is done automatically, but you can call it manually for your own imports:
import pysweepme
# empty argument -> the folder of the calling script is used
pysweepme.addFolderToPATH(r"C:\MyDrivers\SMU-Keithley_2400")
See also
- Pysweepme – using SweepMe! drivers and submodules from your own Python scripts
- Configuration File
- External libraries and dependencies