Exemplo n.º 1
0
 def __init__(self, file, **kwargs):
     highlight = file.split("/")[0]
     master = Template.from_file(
         Utilities.getAppPrefix('gui', 'tpl', 'global', 'master.html'))
     content = open(Utilities.getAppPrefix('gui', 'tpl', file)).read()
     merged = master.render(content=content, highlight=highlight)
     super(HTMLTemplate, self).__init__(merged, **kwargs)
Exemplo n.º 2
0
def choose():
    print """
What do you want to do?\n\
------TRACKS-------\n\
[a]  = get list of all tracks\n\
[b]  = select and export tracks (to default format) | [b?] to select format or [b <format>]\n\
[c]  = export all tracks (to default format)        | [c?] to select format or [c <format>]\n\
[d]  = upload tracks\n\
-----WAYPOINTS-----\n\
[e]  = download waypoints\n\
[f]  = upload waypoints\n\
-----ETC-----------\n\
[gg] = format tracks\n\
[hh] = format waypoints\n\
[i]  = get device information\n\
-------------------\n\
[q] = quit"""

    command = raw_input("=>").strip()
    
    if command == "a":
        print "Getting tracklist"
        tracklist()
    
    elif command.startswith("b"):
        print "Export track(s)"
        
        if command.startswith("b!"):
            command = command[0] + command[2:]
        else:
            tracklist()
        
        picks = raw_input("enter trackID(s) [space delimited] ").strip()
        #adds the slice notation for selecting tracks, i.e. [2:4] or [:-4] or [3]
        if ":" in picks:
            lower, upper = picks.split(':')
            try:
                lower = int(lower)
            except ValueError:
                lower = None
            try:
                upper = int(upper)
            except ValueError:
                upper = None

            trackIds = gh.getAllTrackIds()[lower:upper]
        elif "-" in picks:
            trackIds = [gh.getAllTrackIds()[int(picks)]]
        else:
            trackIds = picks.split(' ')
            
        if command == "b?":
            format = prompt_format()
        elif command.startswith("b "):
            format = command[2:].strip() 
        else:
            format = gh.config.get("export", "default")
            print "FYI: Exporting to default format '%s' (see config.ini)" % format
        
        ef = ExportFormat(format)
        merge = False
        if ef.hasMultiple and len(trackIds) > 1:
            merge = raw_input("Do you want to merge all tracks into a single file? [y/n]: ").strip()
            merge = True if merge == "y" else False
        
        tracks = gh.getTracks(trackIds)
        gh.exportTracks(tracks, format, merge = merge)
        print 'exported %i tracks' % len(tracks)
        
    elif command.startswith("c"):
        print "Export all tracks"
        if command == "c?":
            format = prompt_format()
        elif command.startswith("c "):
            format = command[2:].strip() 
        else:
            format = gh.config.get("export", "default")
            print "FYI: Exporting to default format '%s' (see config.ini)" % format
        
        tracks = gh.getAllTracks()
        results = gh.exportTracks(tracks, format)
        print 'exported %i tracks to %s' % (len(tracks), format)
        
    elif command == "d":
        print "Upload Tracks"
        files = glob.glob(os.path.join(Utilities.getAppPrefix(), "import", "*.gpx"))
        for i,format in enumerate(files):
            (filepath, filename) = os.path.split(format)
            #(shortname, extension) = os.path.splitext(filename)
            print '[%i] = %s' % (i, filename)
        
        fileId = raw_input("enter number(s) [space delimited] ").strip()
        fileIds = fileId.split(' ');
        
        filesToBeImported = []
        for fileId in fileIds:
            filesToBeImported.append(files[int(fileId)])
                    
        tracks = gh.importTracks(filesToBeImported)        
        results = gh.setTracks(tracks)
        print 'successfully uploaded tracks ', str(results)
        
    elif command == "e":
        print "Download Waypoints"
        waypoints = gh.getWaypoints()    
        results = gh.exportWaypoints(waypoints)
        print 'exported Waypoints to', results
        
    elif command == "f":
        print "Upload Waypoints"
        waypoints = gh.importWaypoints()        
        results = gh.setWaypoints(waypoints)
        print 'Imported %i Waypoints' % results
        
    elif command == "gg":
        print "Delete all Tracks"
        warning = raw_input("warning, DELETING ALL TRACKS").strip()
        results = gh.formatTracks()
        print 'Deleted all Tracks:', results
        
    elif command == "hh":
        print "Delete all Waypoints"
        warning = raw_input("WARNING DELETING ALL WAYPOINTS").strip()
        results = gh.formatWaypoints()
        print 'Formatted all Waypoints:', results
    
    elif command == "i":
        unit = gh.getUnitInformation()
        print "* %s waypoints on watch" % unit['waypoint_count']
        print "* %s trackpoints on watch" % unit['trackpoint_count']
    
    elif command == "x":
        print prompt_format()
    
    elif command == "q":
        sys.exit()
        
    else:
        print "whatever"
    
    choose()
Exemplo n.º 3
0
    @cherrypy.expose
    def index(self):
        template = HTMLTemplate('global/error.html')
        return template.render()


print "Connecting to your GH..."
gh = GH600()
#if gh.testConnectivity():
#SITEMAP
root = Root()
root.waypoints = Waypoints()
root.settings = Settings()
#else:
#    root = Error()
#    root.settings = Settings()
cherrypy.tree.mount(root, config="gui/app.conf")


def launch_browser():
    print "Gui running"
    print "Your browser will now be pointed to %s" % cherrypy.server.base()
    print "When you are done, just close this window"
    webbrowser.open(cherrypy.server.base())


cherrypy.engine.subscribe('start', launch_browser)

if __name__ == '__main__':
    cherrypy.quickstart(config=Utilities.getAppPrefix('gui', 'cherrypy.conf'))
Exemplo n.º 4
0
def choose():
    print """
What do you want to do?\n\
------TRACKS-------\n\
[a]  = get list of all tracks\n\
[b]  = select and export tracks (to default format) | [b?] to select format or [b <format>]\n\
[c]  = export all tracks (to default format)        | [c?] to select format or [c <format>]\n\
[d]  = upload tracks\n\
-----WAYPOINTS-----\n\
[e]  = download waypoints\n\
[f]  = upload waypoints\n\
-----ETC-----------\n\
[gg] = format tracks\n\
[hh] = format waypoints\n\
[i]  = get device information\n\
-------------------\n\
[q] = quit"""

    command = raw_input("=>").strip()

    if command == "a":
        print "Getting tracklist"
        tracklist()

    elif command.startswith("b"):
        print "Export track(s)"

        if command.startswith("b!"):
            command = command[0] + command[2:]
        else:
            tracklist()

        picks = raw_input("enter trackID(s) [space delimited] ").strip()
        #adds the slice notation for selecting tracks, i.e. [2:4] or [:-4] or [3]
        if ":" in picks:
            lower, upper = picks.split(':')
            try:
                lower = int(lower)
            except ValueError:
                lower = None
            try:
                upper = int(upper)
            except ValueError:
                upper = None

            trackIds = gh.getAllTrackIds()[lower:upper]
        elif "-" in picks:
            trackIds = [gh.getAllTrackIds()[int(picks)]]
        else:
            trackIds = picks.split(' ')

        if command == "b?":
            format = prompt_format()
        elif command.startswith("b "):
            format = command[2:].strip()
        else:
            format = gh.config.get("export", "default")
            print "FYI: Exporting to default format '%s' (see config.ini)" % format

        ef = ExportFormat(format)
        merge = False
        if ef.hasMultiple and len(trackIds) > 1:
            merge = raw_input(
                "Do you want to merge all tracks into a single file? [y/n]: "
            ).strip()
            merge = True if merge == "y" else False

        tracks = gh.getTracks(trackIds)
        gh.exportTracks(tracks, format, merge=merge)
        print 'exported %i tracks' % len(tracks)

    elif command.startswith("c"):
        print "Export all tracks"
        if command == "c?":
            format = prompt_format()
        elif command.startswith("c "):
            format = command[2:].strip()
        else:
            format = gh.config.get("export", "default")
            print "FYI: Exporting to default format '%s' (see config.ini)" % format

        tracks = gh.getAllTracks()
        results = gh.exportTracks(tracks, format)
        print 'exported %i tracks to %s' % (len(tracks), format)

    elif command == "d":
        print "Upload Tracks"
        files = glob.glob(
            os.path.join(Utilities.getAppPrefix(), "import", "*.gpx"))
        for i, format in enumerate(files):
            (filepath, filename) = os.path.split(format)
            #(shortname, extension) = os.path.splitext(filename)
            print '[%i] = %s' % (i, filename)

        fileId = raw_input("enter number(s) [space delimited] ").strip()
        fileIds = fileId.split(' ')

        filesToBeImported = []
        for fileId in fileIds:
            filesToBeImported.append(files[int(fileId)])

        tracks = gh.importTracks(filesToBeImported)
        results = gh.setTracks(tracks)
        print 'successfully uploaded tracks ', str(results)

    elif command == "e":
        print "Download Waypoints"
        waypoints = gh.getWaypoints()
        results = gh.exportWaypoints(waypoints)
        print 'exported Waypoints to', results

    elif command == "f":
        print "Upload Waypoints"
        waypoints = gh.importWaypoints()
        results = gh.setWaypoints(waypoints)
        print 'Imported %i Waypoints' % results

    elif command == "gg":
        print "Delete all Tracks"
        warning = raw_input("warning, DELETING ALL TRACKS").strip()
        results = gh.formatTracks()
        print 'Deleted all Tracks:', results

    elif command == "hh":
        print "Delete all Waypoints"
        warning = raw_input("WARNING DELETING ALL WAYPOINTS").strip()
        results = gh.formatWaypoints()
        print 'Formatted all Waypoints:', results

    elif command == "i":
        unit = gh.getUnitInformation()
        print "* %s waypoints on watch" % unit['waypoint_count']
        print "* %s trackpoints on watch" % unit['trackpoint_count']

    elif command == "x":
        print prompt_format()

    elif command == "q":
        sys.exit()

    else:
        print "whatever"

    choose()
Exemplo n.º 5
0
 def __init__(self, file, **kwargs):
     highlight = file.split("/")[0]
     master = Template.from_file(Utilities.getAppPrefix('gui', 'tpl', 'global', 'master.html'))
     content = open(Utilities.getAppPrefix('gui', 'tpl', file)).read()
     merged = master.render(content=content, highlight=highlight)
     super(HTMLTemplate, self).__init__(merged, **kwargs)
Exemplo n.º 6
0
            gh.config.write(f)
        raise cherrypy.HTTPRedirect('/settings')

class Error:
    @cherrypy.expose
    def index(self):
        template = HTMLTemplate('global/error.html')
        return template.render()

print "Connecting to your GH..."
gh = GH600()
#if gh.testConnectivity():
#SITEMAP
root = Root()
root.waypoints = Waypoints()
root.settings = Settings()
#else:
#    root = Error()
#    root.settings = Settings()
cherrypy.tree.mount(root, config="gui/app.conf")

def launch_browser():
    print "Gui running"
    print "Your browser will now be pointed to %s" % cherrypy.server.base()
    print "When you are done, just close this window"
    webbrowser.open(cherrypy.server.base())
cherrypy.engine.subscribe('start', launch_browser)

if __name__ == '__main__':
    cherrypy.quickstart(config=Utilities.getAppPrefix('gui', 'cherrypy.conf'))