def __init__(self, basedir, serial, name):
        self._path = os.path.join(basedir, str(serial))
        self._serial = serial
        self._name = name

        # Check profile version, if not a new device
        if os.path.isdir(self._path):
            if self.get_profile_version() < self._PROFILE_VERSION:
                raise Device.ProfileVersionException(
                    "Profile version mismatch, too old")
            elif self.get_profile_version() > self._PROFILE_VERSION:
                raise Device.ProfileVersionException(
                    "Profile version mismatch, to new")

        # Create directories
        utilities.makedirs_if_not_exists(self._path)
        for directory in _directories:
            directory_path = os.path.join(self._path, directory)
            utilities.makedirs_if_not_exists(directory_path)

        # Write profile version (If none)
        path = os.path.join(self._path, self._PROFILE_VERSION_FILE)
        if not os.path.exists(path):
            with open(path, 'wb') as f:
                f.write(str(self._PROFILE_VERSION))
Пример #2
0
def main():
    
    # Find out what time it is
    # used for logging filename.
    currentTime = time.strftime("%Y%m%d-%H%M%S")

    # Set up logging
    logger = logging.getLogger("garmin")
    logger.setLevel(logging.DEBUG)
    utilities.makedirs_if_not_exists("logs")
    handler = logging.FileHandler("logs/" + currentTime + "-garmin.log", "w")
    #handler = logging.StreamHandler()

    # If you add new module/logger name longer than the 15 characters just increase the value after %(name).
    # The longest module/logger name now is "garmin.ant.base" and "garmin.ant.easy".
    handler.setFormatter(logging.Formatter(fmt='%(threadName)-10s %(asctime)s  %(name)-15s  %(levelname)-8s  %(message)s (%(filename)s:%(lineno)d)'))

    logger.addHandler(handler)

    try:
        g = Garmin()
        g.start()
    except (Exception, KeyboardInterrupt):
        traceback.print_exc()
        print "Interrupted"
        g.stop()
        sys.exit(1)
Пример #3
0
def main():

    # Find out what time it is
    # used for logging filename.
    currentTime = time.strftime("%Y%m%d-%H%M%S")

    # Set up logging
    logger = logging.getLogger("garmin")
    logger.setLevel(logging.DEBUG)
    utilities.makedirs_if_not_exists("logs")
    handler = logging.FileHandler("logs/" + currentTime + "-garmin.log", "w")
    #handler = logging.StreamHandler()

    # If you add new module/logger name longer than the 15 characters just increase the value after %(name).
    # The longest module/logger name now is "garmin.ant.base" and "garmin.ant.easy".
    handler.setFormatter(
        logging.Formatter(
            fmt=
            '%(threadName)-10s %(asctime)s  %(name)-15s  %(levelname)-8s  %(message)s (%(filename)s:%(lineno)d)'
        ))

    logger.addHandler(handler)

    try:
        g = Garmin()
        g.start()
    except (Exception, KeyboardInterrupt):
        traceback.print_exc()
        print "Interrupted"
        g.stop()
        sys.exit(1)
Пример #4
0
 def write_passkey(self, serial, passkey):
 
     path = os.path.join(self.config_dir, str(serial))
     utilities.makedirs_if_not_exists(path)
     utilities.makedirs_if_not_exists(os.path.join(path, "activities"))
     
     with open(os.path.join(path, "authfile"), 'wb') as f:
         passkey.tofile(f)
         _logger.debug("wrote authfile: %r, %r", serial, passkey)
Пример #5
0
 def write_passkey(self, serial, passkey):
 
     path = os.path.join(self.config_dir, str(serial))
     utilities.makedirs_if_not_exists(path)
     utilities.makedirs_if_not_exists(os.path.join(path, "activities"))
     
     with open(os.path.join(path, "authfile"), 'wb') as f:
         passkey.tofile(f)
         _logger.debug("wrote authfile: %r, %r", serial, passkey)
Пример #6
0
 def __init__(self):
     Application.__init__(self)
     
     _logger.debug("Creating directories")
     self.config_dir = utilities.XDG(self.PRODUCT_NAME).get_config_dir()
     self.script_dir = os.path.join(self.config_dir, "scripts")
     utilities.makedirs_if_not_exists(self.config_dir)
     utilities.makedirs_if_not_exists(self.script_dir)
     
     self.scriptr  = scripting.Runner(self.script_dir)
Пример #7
0
 def __init__(self):
     Application.__init__(self)
     
     _logger.debug("Creating directories")
     self.config_dir = utilities.XDG(self.PRODUCT_NAME).get_config_dir()
     self.script_dir = os.path.join(self.config_dir, "scripts")
     utilities.makedirs_if_not_exists(self.config_dir)
     utilities.makedirs_if_not_exists(self.script_dir)
     
     self.scriptr  = scripting.Runner(self.script_dir)
    def __init__(self, basedir, serial, name):
        self._path   = os.path.join(basedir, str(serial))
        self._serial = serial
        self._name   = name
        
        # Check profile version, if not a new device
        if os.path.isdir(self._path):
            if self.get_profile_version() < self._PROFILE_VERSION:
                raise Device.ProfileVersionException("Profile version mismatch, too old")
            elif self.get_profile_version() > self._PROFILE_VERSION:
                raise Device.ProfileVersionException("Profile version mismatch, to new")

        # Create directories
        utilities.makedirs_if_not_exists(self._path)
        for directory in _directories:
            directory_path = os.path.join(self._path, directory)
            utilities.makedirs_if_not_exists(directory_path)

        # Write profile version (If none)
        path = os.path.join(self._path, self._PROFILE_VERSION_FILE)
        if not os.path.exists(path):
            with open(path, 'wb') as f:
                f.write(str(self._PROFILE_VERSION))