Skip to content

Commit

Permalink
Don't import serial and usb modules at the top-level.
Browse files Browse the repository at this point in the history
Import them inside SerialLink and USBLink, so that you don't need to
have both installed, if you're only need to use one of them.
  • Loading branch information
Bjorn Tillenius committed Feb 15, 2008
1 parent b342b0b commit 318c576
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions garmin.py
Expand Up @@ -31,10 +31,8 @@

import os, sys, time
import newstruct as struct
import serial
import math
import logging
import usb


# Logging setup. If you want to see debug messages, add a logging
Expand Down Expand Up @@ -1939,6 +1937,9 @@ class SerialLink(P000):
unit_id = None

def __init__(self, device, timeout = 5):
# Import serial here, so that you don't have to have that module
# installed, if you're not using a serial link.
import serial
self.timeout = timeout
self.ser = serial.Serial(device, timeout=self.timeout, baudrate=9600)

Expand Down Expand Up @@ -2054,6 +2055,9 @@ class USBLink:
Pid_Session_Started = 6

def __init__(self):
# Import usb here, so that you don't have to have that module
# installed, if you're not using a usb link.
import usb
self.garmin_dev = None
for bus in usb.busses():
for dev in bus.devices:
Expand Down

0 comments on commit 318c576

Please sign in to comment.