Skip to content

Commit

Permalink
Merge pull request #35 from autolab-project/v2.0
Browse files Browse the repository at this point in the history
V2.0
  • Loading branch information
Python-simulation authored Oct 11, 2024
2 parents f37d136 + eccf5c0 commit a33c5db
Show file tree
Hide file tree
Showing 104 changed files with 8,244 additions and 5,095 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ build/
*.egg-info/

# Sphinx documentation
docs/hmtl/
docs/latexpdf/
docs/html/
docs/latexpdf/
*.stats
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![PyPi](https://img.shields.io/pypi/v/autolab)](https://pypi.org/project/autolab/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/autolab)
[![PyPI Downloads](https://img.shields.io/pypi/dm/autolab.svg?label=PyPI%20downloads)](https://pypi.org/project/autolab/)

[![Documentation Status](https://readthedocs.org/projects/autolab/badge/?version=latest)](https://autolab.readthedocs.io/en/latest/?badge=latest)

# Autolab
Expand All @@ -17,10 +20,10 @@ Visit https://autolab.readthedocs.io/ for the full documentation of this package

## Overview

![Autolab scheme](docs/scheme.png)
<img src="https://raw.githubusercontent.com/autolab-project/autolab/master/docs/scheme.png">

## GUI example

![Autolab Scanning GUI](docs/gui/scanning.png)
<img src="https://raw.githubusercontent.com/autolab-project/autolab/master/docs/gui/scanning.png">

![Autolab Control Panel GUI](docs/gui/control_panel.png)
<img src="https://raw.githubusercontent.com/autolab-project/autolab/master/docs/gui/control_panel.png">
24 changes: 19 additions & 5 deletions autolab/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import socket # OPTIMIZE: temporary fix to an infinite loading on some computer

# Load current version in version file
from .core import paths as _paths
with open(_paths.VERSION) as version_file:
from .core.paths import PATHS, DRIVER_SOURCES
with open(PATHS['version']) as version_file:
__version__ = version_file.read().strip()
del version_file

Expand All @@ -36,11 +36,21 @@
_config.add_extra_driver_path()
_config.add_extra_driver_repo_url()

# Add drivers folder to sys (allows a driver to import another driver)
import sys
# Order of append between local and official matter for priority
for folder in reversed(list(DRIVER_SOURCES.values())):
sys.path.append(folder)
del sys
del folder

# infos
from .core.infos import list_devices, list_drivers, infos, config_help
from .core.infos import infos, config_help
from .core.infos import _list_devices as list_devices
from .core.infos import _list_drivers as list_drivers

# Devices
from .core.devices import get_device, close
from .core.devices import get_device, close, list_loaded_devices
from .core import devices as _devices

# Drivers
Expand All @@ -54,7 +64,11 @@
from .core.server import Server as server

# GUI
from .core.gui import gui, plotter, monitor, slider, add_device, about, variables_menu
from .core.gui import (gui, plotter, monitor, slider, add_device, about,
variables_menu, preferences, driver_installer)

from .core.variables import get_variable, list_variables
from .core.variables import set_variable as add_variable

# Repository
from .core.repository import install_drivers
Expand Down
Binary file modified autolab/autolab.pdf
Binary file not shown.
14 changes: 9 additions & 5 deletions autolab/core/_create_shortcut.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,24 @@
import os
import sys

from .gui.icons import icons
from .utilities import input_wrap


def create_shortcut(ask: bool = False):
""" Create Autolab GUI shortcut on desktop. """
# Works on Windows with winpython and with base or env conda
try:
autolab_icon = icons['autolab']
autolab_icon = os.path.join(
os.path.dirname(__file__), 'gui',
'icons', 'autolab-icon.ico').replace("\\", "/")
userprofile = os.path.expanduser('~')
desktop = os.path.join(userprofile, 'Desktop')
link = os.path.join(desktop, 'Autolab GUI.lnk')
python = sys.base_prefix
python_env = sys.prefix

if not os.path.exists(desktop):
return
return None

is_conda = os.path.exists(os.path.join(sys.prefix, 'conda-meta'))

Expand All @@ -39,7 +40,7 @@ def create_shortcut(ask: bool = False):
python_script = os.path.normpath(os.path.join(python, r'Scripts/activate.bat'))

if not os.path.exists(python_script):
return
return None

from comtypes.client import CreateObject
from comtypes.persist import IPersistFile
Expand All @@ -51,7 +52,7 @@ def create_shortcut(ask: bool = False):
ans = 'yes'

if ans.strip().lower() == 'no':
return
return None

s = CreateObject(ShellLink)
s.SetPath('cmd.exe')
Expand All @@ -63,5 +64,8 @@ def create_shortcut(ask: bool = False):
p = s.QueryInterface(IPersistFile)
p.Save(link, True)

if not os.path.exists(os.path.join(python_env, r'Scripts/autolab.exe')):
print('Warning autolab has not been installed with pip, the shortcut will not work')

except Exception as e:
print(f'Cannot create Autolab shortcut: {e}')
Loading

0 comments on commit a33c5db

Please sign in to comment.