A collection of Python scripts to interact with the SURF Research Drive API, offering utilities for managing and reporting on project folders. Each script is designed to perform a specific function, such as generating reports, generating overview of access permissions, and creating new project folders following predefined naming conventions.
- Generate Excel Table of Project Folders: Retrieve all available project folders and save them as an Excel table.
- Access Permissions Report: Create an overview of folder and file permissions presented in an intuitive HTML table.
- Create Project Folders: Create new project folders following a predefined naming convention.
researchdrive-utils/
├── src/
| ├── researchdrive.py # Python wrapper to interact with the SURF Research Drive API
| ├── scripts/
| | ├── researchdrive_projectfolders.py # Script to create an Excel table of project folders
| | ├── researchdrive_projectfolders.cfg.tmpl # Template config file for the project folders script
| | ├── researchdrive_report.py # Script to generate an access permissions report
| | ├── researchdrive_create_projectfolder.py # Script to create a new project folder
| | ├── researchdrive_create_projectfolder.cfg.tmpl # Template config file for the create project folder script
-
Clone the repository:
git clone https://github.com/yourusername/researchdrive-utils.git cd researchdrive-utils -
Install the package in editable mode from the current directory (including required dependencies):
pip install -e . -
Configure each script (except
researchdrive_report.py) using the corresponding.cfg.tmpltemplate:- Rename the
.cfg.tmplfile to.cfg. - obtain an API token and make sure
Reportingis enabled in the SURF Research Drive Dashboard (see SURF Research Drive wiki) - Update the configuration with your credentials and desired settings.
- Rename the
python researchdrive_projectfolders.py -c researchdrive_projectfolders.cfg- Purpose: Retrieves available project folders and saves an overview in an Excel table.
- Configuration: Ensure
researchdrive_projectfolders.cfgis properly configured.
python researchdrive_report.py -f "SURF Reporting.xlsx"- Purpose: Generates a detailed HTML report of access permissions for folders and files per projectfolder.
- Configuration: Download an
SURF Reporting.xlsxfile from the Research Drive Reporting underProjects->Sharing.
python researchdrive_create_projectfolder.py -c researchdrive_create_projectfolder.cfg- Purpose: Creates a new project folder following a predefined naming convention.
- Configuration: Ensure
researchdrive_create_projectfolder.cfgis properly configured.
Each script requires a configuration file in .cfg format to run. The repository provides .cfg.tmpl templates for each script. Follow these steps to use them:
- Copy the template file and rename it (e.g.,
researchdrive_projectfolders.cfg.tmpl→researchdrive_projectfolders.cfg). - Edit the
.cfgfile to include the necessary settings, such as API tokens, folder paths, or other options.
To create standalone executable files for the scripts using PyInstaller, follow these instructions:
-
Install PyInstaller:
pip install pyinstaller
-
Run the following command for each script to build a standalone executable:
pyinstaller --onefile --icon=RDRIVE.png src/scripts/researchdrive_report.py
Replace
src/scripts/researchdrive_report.pywith the relative path to the script you want to build.--onefile: Creates a single, standalone executable file.--icon=RDRIVE.png: Sets the icon for the executable file.
-
After running PyInstaller, the generated executable file will be available in the
dist/directory.
To build executables for all scripts, run:
pyinstaller --onefile --icon=RDRIVE.png src/scripts/researchdrive_projectfolders.py
pyinstaller --onefile --icon=RDRIVE.png src/scripts/researchdrive_report.py
pyinstaller --onefile --icon=RDRIVE.png src/scripts/researchdrive_create_projectfolder.py- Ensure that
RDRIVE.pngis in the main folder (same directory assetup.py). - The resulting executable files will work independently of Python, making them easy to distribute.
- The resulting executable files only work on the platform they are build for.
researchdrive_projectfolders.exe -c researchdrive_projectfolders.cfg
researchdrive_report.exe -f "SURF Reporting.xlsx"
researchdrive_create_projectfolder.exe -c researchdrive_create_projectfolder.cfgresearchdrive_projectfolders -c researchdrive_projectfolders.cfg
researchdrive_report -f "SURF Reporting.xlsx"
researchdrive_create_projectfolder -c researchdrive_create_projectfolder.cfgContributions are welcome! If you have suggestions for improvements or additional features, feel free to open an issue or submit a pull request.
This repository is licensed under the MIT License. See the LICENSE file for more details.