BCDA-APS / adl2pydm

Convert MEDM's .adl files to PyDM's .ui format
Other
0 stars 4 forks source link

TypeError when using PyDM: expected str, bytes or os.PathLike object, not NoneType #60

Closed prjemian closed 2 years ago

prjemian commented 2 years ago

Describe the bug

Receiving this exception when starting PyDM 1.11.1 today:

[2021-10-22 13:41:24,332] [INFO    ] - file not found: stylesheet.qss
[2021-10-22 13:41:24,332] [INFO    ] - writing screen file: None
Traceback (most recent call last):
  File "/home/prjemian/.conda/envs/bluesky_2021_2/lib/python3.8/site-packages/pydm/widgets/related_display_button.py", line 348, in open_display
    load_file(fname, macros=macros, target=screen_target)
  File "/home/prjemian/.conda/envs/bluesky_2021_2/lib/python3.8/site-packages/pydm/display.py", line 60, in load_file
    app.new_pydm_process(file, macros=macros, command_line_args=args)
  File "/home/prjemian/.conda/envs/bluesky_2021_2/lib/python3.8/site-packages/pydm/application.py", line 159, in new_pydm_process
    ui_file = os.path.expanduser(os.path.expandvars(ui_file))
  File "/home/prjemian/.conda/envs/bluesky_2021_2/lib/python3.8/posixpath.py", line 284, in expandvars
    path = os.fspath(path)
TypeError: expected str, bytes or os.PathLike object, not NoneType

To Reproduce

Start docker xxx IOC on linux:

start_xxx.sh gp

Copy start_MEDM_gp bash script to start_PyDM_gp and modify to read:

#!/bin/bash

# Requires PyDM and adl2pydm python packages

# export EPICS_APP=`dirname ${BASH_SOURCE:-$0}`
export EPICS_APP=/tmp/docker_ioc/iocgp/xxx-R6-2
export EPICS_APP_ADL_DIR=${EPICS_APP}/xxxApp/op/adl
export DEFAULT_UI_FILE=${DEFAULT_UI_FILE:-xxx.adl}

export EPICS_DISPLAY_PATH=/tmp/docker_ioc/iocgp/xxx-R6-2/xxxApp/op/adl
export EPICS_DISPLAY_PATH+=:/tmp/docker_ioc/custom-synapps-6.2/screens/adl
export PYDM_DISPLAYS_PATH="${EPICS_DISPLAY_PATH}"

if [ -z "${MEDM_EXEC_LIST}" ] 
then
    export MEDM_EXEC_LIST='Probe;probe &P &'
fi

#export EPICS_CA_ADDR_LIST="164.54.53.126"

# This should agree with the environment variable set by the ioc
# see 'putenv "EPICS_CA_MAX_ARRAY_BYTES=64008"' in iocBoot/ioc<target>/st.cmd
export EPICS_CA_MAX_ARRAY_BYTES=64008

export START_PUTRECORDER=${EPICS_APP}/start_putrecorder
export MACROS_PY=${EPICS_APP_ADL_DIR}/../python/macros.py
export EDITOR=nedit

export OPTIONS=
export OPTIONS+=" --hide-nav-bar"  # Start with navigation bar hidden
export OPTIONS+=" --hide-menu-bar"  # Start with menu bar hidden
export OPTIONS+=" --hide-status-bar"  # Start with status bar hidden

pydm ${OPTIONS} ${1:-${DEFAULT_UI_FILE}} $* &

Run start_PyDM_gp and see main screen: xxx main screen in PyDM

Click on any of the pop-up menu items and error (above) appears.

Expected behavior New screen should appear.

prjemian commented 2 years ago

Looks like a byte string problem.

prjemian commented 2 years ago

Also, the Moving indicator is not changing and the All Stop button is not responding. On the plus side, the pop-up menu works.

prjemian commented 2 years ago

Not a byte string problem.

Tested for this by first converting all necessary MEDM files to PyDM and starting with only PyDM's .ui files (ignoring any extra graphics files needed by some screens).

export PYDM_DISPLAYS_PATH=/tmp/screens/
mkdir ${PYDM_DISPLAYS_PATH}

adl2pydm -d ${PYDM_DISPLAYS_PATH} /tmp/docker_ioc/custom-synapps-6.2/screens/adl/*.adl
adl2pydm -d ${PYDM_DISPLAYS_PATH} /tmp/docker_ioc/iocgp/xxx-R6-2/xxxApp/op/adl/*.adl

pydm --hide-{nav,menu,status}-bar xxx.ui &

This is a problem in the PyDM application directly, in display.py, line 57:

    if target == ScreenTarget.NEW_PROCESS:
        # Invoke PyDM to open a new process here.
        app = QApplication.instance()
        app.new_pydm_process(file, macros=macros, command_line_args=args)
        return None

A new process is requested for the new screen. The code above bypasses the checks for .adl file extension and the call to app.new_pydm_process(file,... does not handle .adl files. This is a bug in PyDM. PyDM is not fully prepared to handle only .adl files with automatic internal conversion to .ui.

prjemian commented 2 years ago

Can close this issue as wontfix here once an issue is filed with PyDM's issue tracker.

prjemian commented 2 years ago

Propose some resolution in a PR to PyDM.

prjemian commented 2 years ago

PR filed upstream, this issue can be closed now