archive-org.com » ORG » B » BITPIM.ORG

Total: 282

Choose link from "Titles, links and description words view":

Or switch to "Titles and links view".
  • BitPim - an application in Python
    purpose of the talk was to show the developer side of a non trivial application written in Python It highlights issues and choices and what I picked for BitPim and why Other choices may be applicable for other projects Two

    Original URL path: http://bitpim.org/papers/baypiggies/note0.html (2016-02-14)
    Open archived version from archive

  • BitPim - an application in Python
    in one directory dev No other information USB Aka Python C integration is easy Libusb provides good USB access on Windows Linux and Mac SWIG generates Python code wrapping C C Language neutral but best at Python SWIG SWIG is really good Does a good job with raw C C header Is actually simpler than it seems Can pick up cues from parameter names encourage C library implementors Binary strings C C problems highlighted Who owns memory Global pointers Data owned by other data May need C reference counter Poor API design Provide Pythonic layer Multi tasking Can t do two things at the same time Waiting for GUI event Talking to device Talking to network Two approaches Event driven Threading Event driven Twisted asyncore Scales well Harder to write inside out Every library has to work the same way Threading Simpler initially Things can change underneath you Harder to deal with exceptions And the winner was Threading Decouple threads and data as much as possible wxPython event loop integrates well Use Queue Queue to send messages wx PostMessage to send to GUI event queue Sample Code GUI def OnGetFile self self makecall getfile path self OnGetFileResult path def OnGetFileResults self path exception data if exception is not None raise exception def makecall self callfunc args resultfunc resargs self queue put callfunc args resultfunc resargs Sample Code thread loop result exception None callfunc args resultfunc resargs queue get try result callfunc args except exception sys exc info 1 wx PostEvent RESULT EVENT resultfunc resargs exception result Threading and SWIG deal with data being returned int usb bulk read wrapped usb dev handle dev int ep char bytesoutbuffer int bytesoutbuffersize int timeout int res Py BEGIN ALLOW THREADS res usb bulk read dev ep bytesoutbuffer bytesoutbuffersize timeout Py END ALLOW THREADS if res 0 bytesoutbuffersize 0 else bytesoutbuffersize res return res Threading gotchas Python doesn t have thread priorities Nor do the event driven frameworks Cannot interrupt a thread Have to poll variable Use setDaemon for blocking calls eg accept Mismatch in producer consumer rates can have dire effects Update GUI from idle handler Threading techniques Assertions against thread get ident Class instance wrappers Forward requests to correct thread Thread pooling Checking Outlook If you can do it easily from VB you can do it easily from Python win32all Dynamic module generation at runtime cached makepy can generate static module Binary distribution favours latter Outlook code import outlook com app outlook com Application mapi app GetNamespace MAPI contacts mapi GetDefaultFolder constants olFolder for i in range len contacts Items item contacts Items 1 i print item FullName print item MobileTelephoneNumber Evolution vCards stored in berkely db files bsddb module ebook api Significant versioning issues Significant dependency issues vCards No mature Python vCard modules No data source implements vCards correctly anyway 530 lines for vFile parser and vCard data converter Correctly deals with every correct and broken vCard I could find Wisdom Use the highest level language you can afford even if

    Original URL path: http://bitpim.org/papers/baypiggies/outline1.html (2016-02-14)
    Open archived version from archive



  •