friedrich-schotte / Lauecollect

Data Acquisition Software for the BioCARS 14-ID Beamline at the Advanced Photon Source
MIT License
0 stars 1 forks source link

Bug in the timing_sequencer #1

Open vstadnytskyi opened 4 years ago

vstadnytskyi commented 4 years ago

There is a bug in timing_sequence. You are trying to evaluate "object.%s" % name but name is ‘.name’ so you end up with object.._name__

see line https://github.com/friedrich-schotte/Lauecollect/blob/60ae2b05ea8596ba0decf426e37aeaca0bc8b6be/timing_sequence.py#L593

from timing_sequencer import timing_sequencer

In [11]: timing_sequencer.queue_active
Traceback (most recent call last):

  File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3326, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)

  File "<ipython-input-11-db81418e8de0>", line 1, in <module>
    timing_sequencer.queue_active

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/timing_sequence.py", line 220, in get_queue_active
    return self.current_queue_name == self.queue_name

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/timing_sequence.py", line 522, in get
    def get(self): return self.driver_property_get(name,type,default_value,terminator)

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/timing_sequence.py", line 528, in driver_property_get
    value = self.driver_property_get_value(name)

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/timing_sequence.py", line 547, in driver_property_get_value
    if self.use_sequencer_CA:

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/persistent_property.py", line 20, in get
    def get(self): return get_persistent_property(self,name,default_value)

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/persistent_property.py", line 26, in get_persistent_property
    t = dbget(dbname(self,name))

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/persistent_property.py", line 46, in dbname
    elif class_name(self): dbname = class_name(self)+"."+name

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/persistent_property.py", line 52, in class_name
    if hasattr(self,"__name__"): class_name = getattr(self,"__name__","")

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/timing_sequence.py", line 100, in __getattr__
    elif self.hasattr(timing_system,alt_name):

  File "/Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/timing_sequence.py", line 109, in hasattr
    try: eval("object.%s" % name); return True

  File "<string>", line 1
    object.._name__
           ^
SyntaxError: invalid syntax
> /Users/user-13/All-Projects-on-user/APS/Instrumentation/Software/Lauecollect/timing_sequence.py(109)hasattr()
-> try: eval("object.%s" % name); return True
(Pdb) name
'._name__'
vstadnytskyi commented 4 years ago

it is Python3 issue. It works fine on Python2.7

$ ipython
^[[APython 2.7.16 (v2.7.16:413a49145e, Mar  2 2019, 14:32:10)
Type "copyright", "credits" or "license" for more information.

IPython 5.8.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: from timing_sequencer import timing_sequencer

In [2]: timing_sequencer.queue_active
Out[2]: False