Beispiel #1
0
def symlinkExternalProjects():
    config = weioConfig.getConfiguration()

    # Flash
    if (os.path.exists(config["extern_projects_path_flash"])):
        # unlink then link to make sure that path is correct
        try:
            os.remove("www/flash")
        except:
            print "Symlink don't exist. Will create new one for flash"
        os.symlink(config["extern_projects_path_flash"], "www/flash")

    # SD
    if (os.path.exists(config["extern_projects_path_sd"])):
        try:
            os.remove("www/sd")
        except:
            print "Symlink don't exist. Will create new one for sd"
        os.symlink(config["extern_projects_path_sd"], "www/sd")

    # USB Flash
    if (os.path.exists(config["extern_projects_path_usbFlash"])):
        try:
            os.remove("www/usbFlash")
        except:
            print "Symlink don't exist. Will create new one for usbFlash"
        os.symlink(config["extern_projects_path_usbFlash"], "www/usbFlash")
Beispiel #2
0
def symlinkExternalProjects():
    config = weioConfig.getConfiguration()

    # Flash
    if (os.path.exists(config["extern_projects_path_flash"])):
        # unlink then link to make sure that path is correct
        try :
            os.remove("www/flash")
        except:
            print "Symlink don't exist. Will create new one for flash"
        os.symlink(config["extern_projects_path_flash"], "www/flash")

    # SD
    if (os.path.exists(config["extern_projects_path_sd"])):
        try :
            os.remove("www/sd")
        except:
            print "Symlink don't exist. Will create new one for sd"
        os.symlink(config["extern_projects_path_sd"], "www/sd")

    # USB Flash
    if (os.path.exists(config["extern_projects_path_usbFlash"])):
        try :
            os.remove("www/usbFlash")
        except:
            print "Symlink don't exist. Will create new one for usbFlash"
        os.symlink(config["extern_projects_path_usbFlash"], "www/usbFlash")
Beispiel #3
0
def checkForUpdates():
    data = {}
    if (isConnected("www.puzzle-lab.com") or isConnected("www.github.com")):
        config = weioConfig.getConfiguration()
        repository = ""
        print "REPO", config["weio_update_use_official_repository"]
        if (config["weio_update_use_official_repository"] == "YES"):
            repository = config["weio_update_official_repository"]
        else:
            repository = config["weio_update_alternate_repository"]

        h = httputil.HTTPHeaders({
            "Accept": "application/vnd.github.v3+json",
            "User-Agent": "weio"
        })
        req = None
        if (config["weio_update_use_official_repository"] == "YES"):
            req = httpclient.HTTPRequest(repository, headers=h)
        else:
            req = httpclient.HTTPRequest(repository)

        http_client = httpclient.AsyncHTTPClient()
        http_client.fetch(req, callback=serverData)
    else:
        # not connected to the internet
        print "NO INTERNET CONNECTION"
        data['serverPush'] = "noInternetConnection"
        data['data'] = "Can't reach Internet servers"
Beispiel #4
0
def checkForUpdates():
    data = {}
    if (isConnected("we-io.net") or isConnected("www.github.com")):
        config = weioConfig.getConfiguration()
        repository = ""
        print "REPO", config["weio_update_use_official_repository"]
        if (config["weio_update_use_official_repository"] == "YES") :
            repository = config["weio_update_official_repository"]
        else :
            repository = config["weio_update_alternate_repository"]

        h = httputil.HTTPHeaders({"Accept" : "application/vnd.github.v3+json","User-Agent" : "weio"})
        req = None
        if (config["weio_update_use_official_repository"] == "YES"):
            req = httpclient.HTTPRequest(repository, headers=h)
        else :
            req = httpclient.HTTPRequest(repository)

        http_client = httpclient.AsyncHTTPClient()
        http_client.fetch(req, callback=serverData)
    else :
        # not connected to the internet
        print "NO INTERNET CONNECTION"
        data['serverPush'] = "noInternetConnection"
        data['data'] = "Can't reach Internet servers"
Beispiel #5
0
def symlinkExternalProjects():
    config = weioConfig.getConfiguration()

    # Examples
    if (os.path.lexists(config["absolut_root_path"] + "/examples")):
        # unlink then link to make sure that path is correct
        try:
            os.unlink("www/examples")
        except:
            print "Symlink don't exist. Will create new one for examples"
        os.symlink(config["absolut_root_path"] + "/examples", "www/examples")

    # Flash
    if (os.path.lexists(config["extern_projects_path_flash"])):
        # unlink then link to make sure that path is correct
        try:
            os.unlink("www/flash")
        except:
            print "Symlink don't exist. Will create new one for flash"
        os.symlink(config["extern_projects_path_flash"], "www/flash")

    # SD
    if (os.path.lexists(config["extern_projects_path_sd"])):
        try:
            os.unlink("www/sd")
        except:
            print "Symlink don't exist. Will create new one for sd"
        os.symlink(config["extern_projects_path_sd"], "www/sd")

    # USB Flash
    if (os.path.lexists(config["extern_projects_path_usbFlash"])):
        try:
            os.unlink("www/usbFlash")
        except:
            print "Symlink don't exist. Will create new one for usbFlash"
        os.symlink(config["extern_projects_path_usbFlash"], "www/usbFlash")

    # Re-link current project's www
    lastStorage = os.path.basename(
        os.path.dirname(config["last_opened_project"]))
    lastWww = config["last_opened_project"] + '/' + 'www'
    #print "LS ", lastStorage
    if (lastStorage != "sd" and lastStorage != "usbFlash"):
        if os.path.lexists(lastWww):
            try:
                os.unlink(lastWww)
            except:
                print "Symlink don't exist. Will create new one for www"
            if (len(config["last_opened_project"]) > 0):
                os.symlink(config["absolut_root_path"] + "/www", lastWww)
Beispiel #6
0
def symlinkExternalProjects():
    config = weioConfig.getConfiguration()

    # Examples
    if ( os.path.lexists(config["absolut_root_path"] + "/examples") ):
        # unlink then link to make sure that path is correct
        try:
            os.unlink("www/examples")
        except:
            print "Symlink don't exist. Will create new one for examples"
        os.symlink(config["absolut_root_path"] + "/examples", "www/examples")

    # Flash
    if (os.path.lexists(config["extern_projects_path_flash"])):
        # unlink then link to make sure that path is correct
        try:
            os.unlink("www/flash")
        except:
            print "Symlink don't exist. Will create new one for flash"
        os.symlink(config["extern_projects_path_flash"], "www/flash")

    # SD
    if (os.path.lexists(config["extern_projects_path_sd"])):
        try:
            os.unlink("www/sd")
        except:
            print "Symlink don't exist. Will create new one for sd"
        os.symlink(config["extern_projects_path_sd"], "www/sd")

    # USB Flash
    if (os.path.lexists(config["extern_projects_path_usbFlash"])):
        try:
            os.unlink("www/usbFlash")
        except:
            print "Symlink don't exist. Will create new one for usbFlash"
        os.symlink(config["extern_projects_path_usbFlash"], "www/usbFlash")

    # Re-link current project's www
    lastStorage = os.path.basename(os.path.dirname(config["last_opened_project"]))
    lastWww = config["last_opened_project"] + '/' + 'www'
    #print "LS ", lastStorage
    if (lastStorage != "sd" and lastStorage != "usbFlash"):
        if os.path.lexists(lastWww):
            try:
                os.unlink(lastWww)
            except:
                print "Symlink don't exist. Will create new one for www"
            if (len(config["last_opened_project"]) > 0):
                os.symlink(config["absolut_root_path"] + "/www", lastWww)
Beispiel #7
0
def serverData(response):
    print response.body
    config = weioConfig.getConfiguration()

    data = json.loads(response.body)
    lastUpdate = data[0]
    found = False
    for file in lastUpdate["assets"]:
        if ("weio_recovery.bin" in file["name"]):
            print "found weio_recovery"
            fwDownloadLink = file["browser_download_url"]
            fwDownloadSize = file["size"]
            found = True
    if (found == True):
        startDownload(fwDownloadLink, pathToSave)
        sizeOnDisk = os.path.getsize(pathToSave)
        if (fwDownloadSize == sizeOnDisk):
            p = subprocess.Popen(["/etc/init.d/weio_run", "stop"])
            print p.communicate()
            p = subprocess.Popen(["sysupgrade", "-v", pathToSave])
            print p.communicate()
            exit()
        else:
            checkForUpdates()
Beispiel #8
0
def serverData(response):
    print response.body
    config = weioConfig.getConfiguration()

    data = json.loads(response.body)
    lastUpdate = data[0]
    found = False
    for file in lastUpdate["assets"]:
        if ("weio_recovery.bin" in file["name"]):
            print "found weio_recovery"
            fwDownloadLink = file["browser_download_url"]
            fwDownloadSize = file["size"]
            found = True
    if (found == True):
        startDownload(fwDownloadLink, pathToSave)
        sizeOnDisk = os.path.getsize(pathToSave)
        if (fwDownloadSize == sizeOnDisk):
            p = subprocess.Popen(["/etc/init.d/weio_run", "stop"])
            print p.communicate()
            p = subprocess.Popen(["sysupgrade", "-v", pathToSave])
            print p.communicate()
            exit()
        else :
            checkForUpdates()