python yast

My colleague David Mulder started a new version of python yast bindings, I've started to use it for some samba related stuff. However my python is poor, my yast UI knowledge is even poorer :-) I'd like to rewrite the ruby yast examples in python, that way I can hopefully learn a bit more about

  • the new python/yast bindings
  • creating UI(s) using yast (with python)
  • find problems and missing functionality with the bindings by getting the examples ported

kodi plugin

Once upon a time there was a plugin for Irish tv, it worked nicely with one of the national stations catchup service. If I have time I'd like to see what can be done to make that plugin work again (or maybe write a new one). I think this might be an aspirational project :-) but at least I'd like to look into it

Looking for mad skills in:

Nothing? Add some keywords!

This project is part of:

Hack Week 16

Activity

  • about 2 years ago: zzhou liked python yast + python kodi plugin
  • about 2 years ago: npower originated python yast + python kodi plugin
  • Show History

    Comments

    • npower
      almost 2 years ago by npower | Reply

      Hackweek update

      python yast

      I had a couple of goals, I believe that I certainly achieved those :-)

      I ported all 235 ruby examples from here

      For quite a while I was porting manually, after spending some time learning what needed to be changed and beginning to understand things more and finally realising my progress was way way too slow I created a really crappy conversion script Note: I realise this is not the optimal way to do a conversion, perhaps another hackweek project would be to learn abit about yacc/bison and write a proper translator. This however suited my need to actually interact with the code to learn some stuff :)

      They are working in the majority of cases.

      I found a few issues with the current python bindings that we are working on.

      summary of the week

      Number of examples: 235

      Number of examples ported: 235

      Number not working: 15-20 approx. With the exception of 1 (SlideShowDemo2.py) all of these are non functional due to missing SCR, Directory and Pkg module/functions

      Issues:

      • missing Builtins functions, currently the builtins used in the examples are calling new python functions in a module called ycpbuiltins (because of a namespace clash with 'builtins') we could probably use a module name of 'Builtins' but afaik convention is for lowercase modules. Note: If the c++ equivelant functions are available then it might make sense to use these. However for some e.g. y2error, y2warning, y2milestone etc. we need to natively wrap these in order to capture the file and line number information from the stack frame to add to the debug message. Currently the python ycpbuiltin module just does that and writes just to stdout at the moment. These functions of course need to call the underlying ycp/c++ code to write to the log file (#TODO) other functions like some of the string and list helpers are probably easier done in native python code. some functions from ycp Builtins (like cryptbigcrypt should be call the appropriate ycp/C++ code)

      • we weren't handling complex Term expressions e.g.

        Term(sometext, somemoretext)

      or

      Term("ShowReleaseNotesButton", "&Release Notes", "release_notes")
      

      etc. The Python bindings are adjusted now to handle that

      • Numeric Id(). The new python bindings were by default just supporting an Id taking a single string param. However lots of the examples were taking int. Just replacing Id(1) with Id('1') worked for lots of the examples but closer to the completing the example conversions I came across some instances where this approach became a little awkward

        UI.ChangeWidget(Id(:table), Cell(@currentitemid, 1), @amount)

      Versus

      UI.ChangeWidget(Id("table"), Cell(Id(str(current_item_id)), 1), amount)
      

      The bindings now support numberic Id(s) like Id(1) etc. the examples ported are are currently coded like Id('1'). It would be good to review and rewrite again those ported examples again to work a little more like they were intended to work

      Note: not only can an int be passed to 'Id' it is also possible (and some of the examples do this) for other params like Term to be used for Id. e.g.

      RadioButton(Id(term(:unit, 0)), Opt(:notify)....)
      

      This is now converted like:

      RadioButton(Id(Term("unit", 0)), Opt("notify")..)

      • Some missing YCP functionality was identified that was preventing some examples from functioning

        • Missing SCR functions
        • Missing Pkg functions
        • Missing Directory functions
      • Handling of escaped string literals for utf-8 doesn't seem to work as expected, this is probably as a result of my poor python skills or something that needs specific handling in the bindings (see RichText1cs.py, SetLanguage.py Table1utf8.py (and others))

      • Use of the Wizard widget directly didn't work, attempting to add a Wizard Term to the existing set of Term functions failed due to namespace issues (with the Wizard module containing the Wizard functions like Wizard.CreateDialog() etc.) I am working around this by introducing YCPWizard in place of the Wizard UI term

      • There are times when ChangeWidget (probably other functions) doen't work as expected out of the box. This seems mainly due to the pattern of conversion we are using where

      in ruby a widget with and Item like

      Item( Id(:opt), "opt", false, ["kde", "netscape", "Office51"
      

      can be selected or changed to via

      UI.ChangeWidget(:dest_dir, :CurrentItem, :opt)
      

      but since we convert such an item as

      Item( Id("opt"), "opt", False, ["kde", "netscape", "Office51"]
      

      we sometimes need to do

       UI.ChangeWidget("dest_dir", "CurrentItem", Symbol("opt"))
      

      or

       UI.ChangeWidget("dest_dir", "CurrentItem", Id("opt"))
      

      similarly the Wizard Widget will not work with our standard conversion

      UI.OpenDialog( Opt(:defaultsize), Wizard( Opt(:stepsEnabled), :back, "&Back", :abort, "Ab&ort", :next, "&Next"))
      

      to

      UI.OpenDialog( Opt("defaultsize"), YCPWizard( Opt("stepsEnabled"), "back", "&Back", "abort", "Ab&ort", "next", "&Next"))
      

      will not work in this case it is necessary to do something like

      UI.OpenDialog(Opt("defaultsize"), YCPWizard( Opt("stepsEnabled"), Symbol("back"), "&Back", Symbol("abort"), "Ab&ort", Symbol("next"), "&Next"))
      

      The use of Id certainly linked with the use of Symbol, currently we automatically convert the string to a symbol if it is passed to Id. However we have seen that Id can take other types. It should be possible that someone may intentionally pass a string and expect it to be used with Id (without the autoconvert to symbol) However for brevity (and since the usecase where Id is a symbo l seems to be 99% of time) the Id function takes an optional param to override the autoconvertion of the string to symbol (see yast.py) * another issue is deep copy on swig objects doesn't work (need to investigate that to see what if anything can be done) * use of None should be converted to Void() causes some cores in places (nil in ruby works fine)

    Similar Projects

    This project is one of its kind!