Results 1 to 3 of 3

Thread: Using python libraries / modules in Lianja

  1. #1

    Post Using python libraries / modules in Lianja


    I have this python program that uses GPSD to read data from a GPS connected to the machine. Here is the code that I use for this purpose. It works perfectly fine as a python program. But how do I get something like this to run within Lianja? How do I handle the imports/modules? I am a newbie to both Lianja / python, and hence the "starter's question"

    #! /usr/bin/python
    # Written by Dan Mandle September 2012
    # License: GPL 2.0
    import os
    from gps import *
    from time import *
    import time
    import threading
    gpsd = None #seting the global variable
    os.system('clear') #clear the terminal (optional)
    class GpsPoller(threading.Thread):
      def __init__(self):
        global gpsd #bring it in scope
        gpsd = gps(mode=WATCH_ENABLE) #starting the stream of info
        self.current_value = None
        self.running = True #setting the thread running to true
      def run(self):
        global gpsd
        while gpsp.running:
 #this will continue to loop and grab EACH set of gpsd info to clear the buffer
    if __name__ == '__main__':
      gpsp = GpsPoller() # create the thread
        gpsp.start() # start it up
        while True:
          #It may take a second or two to get good data
          #print gpsd.fix.latitude,', ',gpsd.fix.longitude,'  Time: ',gpsd.utc
          print ' GPS reading'
          print '----------------------------------------'
          print 'latitude    ' , gpsd.fix.latitude
          print 'longitude   ' , gpsd.fix.longitude
          print 'time utc    ' , gpsd.utc,' + ', gpsd.fix.time
          print 'altitude (m)' , gpsd.fix.altitude
          print 'eps         ' , gpsd.fix.eps
          print 'epx         ' , gpsd.fix.epx
          print 'epv         ' , gpsd.fix.epv
          print 'ept         ' , gpsd.fix.ept
          print 'speed (m/s) ' , gpsd.fix.speed
          print 'climb       ' , gpsd.fix.climb
          print 'track       ' , gpsd.fix.track
          print 'mode        ' , gpsd.fix.mode
          print 'sats        ' , gpsd.satellites
          time.sleep(5) #set to whatever
      except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
        print "\nKilling Thread..."
        gpsp.running = False
        gpsp.join() # wait for the thread to finish what it's doing
      print "Done.\nExiting."
    Thanks & Regards,

  2. #2
    Lianja Team yvonne.milne's Avatar
    Join Date
    Feb 2012
    Berkshire, UK
    Hi Murali,

    With the modules installed in the Lianja Python path under C:\lianja\scriptinglanguages\python\Lib\ (default installation) you should be able to import as in your existing Python code. Check out for information on Registry tweaks that may be required.

    Remember that you can also use the Python tab in the Console Workspace to test out imports (and see any error messages if the modules aren't found) before running your complete script.



  3. #3
    hi Yvonne,

    Great, thanks!


Tags for this Thread



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Journey into the Cloud
Join us