sardana-org / sardana

Moved to GitLab: https://gitlab.com/sardana-org/sardana
39 stars 52 forks source link

defaults MacroPath (SF#384) #230

Open sf-migrator-bot opened 9 years ago

sf-migrator-bot commented 9 years ago

Hello,

At the LPS they are using sardana to control their diffractometer. The Sardana process run as the logged users in order to save the data with the right uid:gid. Now they want to write macros as user but also as administrator of the system in order to prevent user from modifying these macros.

If I look at the msmacromanager, it seems that the DEFAULT_MACRO_DIRECTORIES = os.path.join(_BASE_DIR, 'macros'),

path is is in fact the installed path of Sardana/macro directory. They know that the MacroPath property can be added to the macroserver device in order to add dedicated path to the MAcroserver, BUT, each time they need to log as a different user, they need to ad one more data path.

It would be great if by default Sardana should follow the xdg standards in order to find its macros. This would help a lot.

thanks

Vincent and Fred

Reported by: picca ( http://sf.net/u/piccaf )

Original Ticket: sardana/tickets/384

sf-migrator-bot commented 9 years ago

Once we add the MacroPath

/home/userrix/.config/sardana/macros and add en empty userrix.py file into it When we try to add a new macros, we got this error message

Door_fourc_1 [4]: %lsmaclib
            Name                                                                       Location
 --------------- ------------------------------------------------------------------------------
         userrix                                /home/userrix/.config/sardana/macros/userrix.py
   communication   /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/communication.py
            demo            /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/demo.py
             env             /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/env.py
          expert          /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/expert.py
      ioregister      /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/ioregister.py
           lists           /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/lists.py
             mca             /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/mca.py
            scan            /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/scan.py
        sequence        /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/sequence.py
        standard        /usr/lib/python2.7/dist-packages/sardana/macroserver/macros/standard.py
      hkl_macros                                  /usr/local/share/sardana/macros/hkl_macros.py
Door_fourc_1 [3]: %edmac testmac userrix
Opening userrix.testmac...
Tango exception
Severity = ERROR 
Error reason = PyDs_PythonError
Desc : IOError: (13, 'Permission denied', '/usr/local/share/sardana/macros/userrix.py')

Origin :   File "/usr/lib/python2.7/dist-packages/sardana/tango/macroserver/MacroServer.py", line 281, in GetMacroCode
    ret = self.macro_server.get_or_create_macro_lib(*argin)
  File "/usr/lib/python2.7/dist-packages/sardana/macroserver/macroserver.py", line 539, in get_or_create_macro_lib
    macro_name=macro_name)
  File "/usr/lib/python2.7/dist-packages/sardana/macroserver/msmacromanager.py", line 279, in getOrCreateMacroLib
    f_name, code, line_nb = self.createMacro(lib_name, macro_name)
  File "/usr/lib/python2.7/dist-packages/sardana/macroserver/msmacromanager.py", line 329, in createMacro
    f = open(f_name, 'a+')

Tango exception
Severity = ERROR 
Error reason = API_CommandFailed
Desc : Failed to execute command_inout on device macroserver/fourc/1, command GetMacroCode
Origin : Connection::command_inout()

Original comment by: picca (http://sf.net/u/piccaf)