当前位置: 首页>>代码示例>>Python>>正文


Python weioConfig.getConfiguration函数代码示例

本文整理汇总了Python中weioLib.weioConfig.getConfiguration函数的典型用法代码示例。如果您正苦于以下问题:Python getConfiguration函数的具体用法?Python getConfiguration怎么用?Python getConfiguration使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了getConfiguration函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: updateNetworkData

    def updateNetworkData(self, rq):
        data = {}
        self.dns_name = rq['data']['dns_name']
        self.auto_to_ap = rq['data']['auto_to_ap']

        config = weioConfig.getConfiguration()
        config['dns_name'] = self.dns_name + ".local"
        config['auto_to_ap'] = self.auto_to_ap
      
        if (platform.machine() == 'mips'):
            # Change avahi name
            command = "sh scripts/change_boardname.sh " + self.dns_name
            try:
                subprocess.call(command, shell=True)
                firstTimeSwitch = "NO"
                config['first_time_run']=firstTimeSwitch
                data['data'] = "msg_success"
            except:
                output = "ERR_CMD BRDNAME"
                data['data'] = "msg_fail"
                print output
        else:
            # On PC
            firstTimeSwitch = "NO"
            config['first_time_run']=firstTimeSwitch
            data['data'] = "msg_success"
       
        # Save new user data in config file 
        weioConfig.saveConfiguration(config);
        data['requested'] = "updataNetwork"
        self.send(json.dumps(data))
开发者ID:jordonwu,项目名称:weio,代码行数:31,代码来源:userSettingsHandler.py

示例2: changeProject

    def changeProject(self,rq):
        #print "CHANGE PROJECT", rq
        # get configuration from file
        print "TO CHANGE ", rq
        config = weioConfig.getConfiguration()

        virtPath = rq['data']
        storage = os.path.dirname(virtPath)
        print 'STORAGE', storage
        path = "www/"+virtPath
        print 'STORAGE', path

        config["last_opened_project"] = path
        weioConfig.saveConfiguration(config);

        # In this way we avoid migrations between pc and weio and other archs
        try :
            os.remove(path+"/www")
        except:
            print "Symlink don't exist. Will create new one for www in this project"
        os.symlink(config["absolut_root_path"] + "/www/", path + "/www")

        data = {}
        data['requested'] = rq['request']
        self.broadcast(clients, json.dumps(data))

        rqlist = ["stop", "getLastProjectName", "getUserProjetsFolderList"]

        for i in range(0,len(rqlist)):
            rq['request'] = rqlist[i]
            callbacks[ rq['request'] ](self, rq)
开发者ID:WRTIOT,项目名称:weio,代码行数:31,代码来源:dashboardHandler.py

示例3: decompressNewProject

    def decompressNewProject(self, rq):
        print "decompress"
        f = rq['data']
        name = f['name']
        contents = f['data']
        storageUnit = rq['storageUnit'] +"/"
        #print contents

        # get configuration from file
        confFile = weioConfig.getConfiguration()
        pathCurrentProject = "www/" + storageUnit

        projectName = name.split(".tar")[0]
        data = {}

        if (weioFiles.checkIfDirectoryExists(pathCurrentProject+projectName) is False) :
            #decode from base64, file is binary
            bb = contents
            bb = bb.split(",")[1] # split header, for example: "data:image/jpeg;base64,"
            weioFiles.saveRawContentToFile(pathCurrentProject+name, bb.decode("base64"))
            #print "save to ", pathCurrentProject+name
            weioFiles.createDirectory(pathCurrentProject+projectName)
            #print "mkdir ", pathCurrentProject+"userProjects/"+projectName
            weioFiles.unTarFile(pathCurrentProject+name, pathCurrentProject+projectName)
            #print "untar ", pathCurrentProject+"userProjects/"+projectName

            data['request'] = "changeProject"
            data['data'] = storageUnit+projectName

            self.changeProject(data)
        else :
            data['requested'] = 'status'
            data['status'] = "Error this projet already exists"
            self.broadcast(clients, json.dumps(data))
开发者ID:Capt-Cpt,项目名称:weio,代码行数:34,代码来源:dashboardHandler.py

示例4: createNewFile

    def createNewFile(self, rq):
        data = {}
        # this function is similar to saveFile

        # echo given request
        data['requested'] = rq['request']

        # don't echo given data to spare unnecessary communication, just return name
        f = rq['data']
        name = f['name']
        contents = f['data']

        # get configuration from file
        confFile = weioConfig.getConfiguration()
        print "WILL BE SAVED IN ", name

        if ((".html" in name) or (".py" in name) or (".json" in name) or
            (".css" in name) or (".txt" in name) or (".js" in name) or
            (".md" in name) or (".svg" in name) or (".xml" in name) or
            (".less" in name) or (".coffee" in name)):

            weioFiles.saveRawContentToFile(confFile["last_opened_project"] + "/" + name, contents)
        else :

            #decode from base64, file is binary
            bin = contents
            bin = bin.split(",")[1] # split header, for example: "data:image/jpeg;base64,"
            weioFiles.saveRawContentToFile(confFile["last_opened_project"] + "/" + name, bin.decode("base64"))

        #print (pathCurrentProject+pathname)

        data['status'] = name + " has been created"
        self.broadcast(clients, json.dumps(data))
开发者ID:WRTIOT,项目名称:weio,代码行数:33,代码来源:editorHandler.py

示例5: createTarForProject

    def createTarForProject(self, rq):
        # TEST IF NAME IS OK FIRST
        # get configuration from file
        config = weioConfig.getConfiguration()
        data = {}
        data['requested'] = "status"
        data['status'] = "Making archive..."
        self.broadcast(clients, json.dumps(data))

        data['requested'] = rq['request']

        splitted = config["last_opened_project"].split("/")
        print "CHOOSE NAME", splitted
        lp = splitted[-1]


        if (weioFiles.checkIfDirectoryExists(config["last_opened_project"])):
            weioFiles.createTarfile(config["last_opened_project"] + "/" + lp + ".tar",
                    config["last_opened_project"]+"/")

            data['status'] = "Project archived"
            print "project archived"
        else :
            data['status'] = "Error archiving project"

        self.broadcast(clients, json.dumps(data))
开发者ID:Capt-Cpt,项目名称:weio,代码行数:26,代码来源:dashboardHandler.py

示例6: loadUserProjectMain

    def loadUserProjectMain(self):
        confFile = weioConfig.getConfiguration()

        # Get the last name of project and run it

        projectModule = confFile["last_opened_project"].replace('/', '.') + ".main"
        #print "CALL", projectModule

        result = None

        if (self.lastCalledProjectPath == projectModule):
            #print "RELOADING"
            result = reload(self.userMain)
        else :
            #print "NEW IMPORT"
            # Import userMain from local module
            try :
                userMain = __import__(projectModule, fromlist=[''])
                result = userMain
            except :
                #print "MODULE CAN'T BE LOADED"
                result = None

        self.lastCalledProjectPath = projectModule
        return result
开发者ID:sethkontny,项目名称:weio,代码行数:25,代码来源:weioRunner.py

示例7: newProject

    def newProject(self, rq):
        config = weioConfig.getConfiguration()
        print "NEW PROJECT", rq
        data = {}
        data['requested'] = rq['request']
        path = ""
        storage = rq['storageUnit']

        path = "www/" + rq['storageUnit'] + "/" + rq['path']

        print "CREATE PROJECT", path
        if (len(path)>0):
            if (weioFiles.checkIfDirectoryExists(path)):
                print "ALREADY EXISTS"
                data['status'] = "Can't create project"
                data['error'] = "already exists"
                data['path'] = path
                self.broadcast(clients, json.dumps(data))
            else :
                weioFiles.createDirectory(path)
                # ADD HERE SOME DEFAULT FILES
                # adding __init__.py
                weioFiles.saveRawContentToFile(path + "/__init__.py", "")

                # make symlink to www/
                if (storage == "sd" or storage == "usbFlash"):
                    if (storage == "sd"):
                        if os.path.isdir(path):
                            if not (os.path.exists(path + "/www")):
                                print "COPYING TO ", path + "/www"
                                copytree(config["absolut_root_path"] + "/www/", path + "/www", ignore=ignore_patterns('sd', 'flash', 'examples', 'usbFlash'))
                                print "OK"
                    else:
                        if not (os.path.exists(path + "/www")):
                            print "COPYING TO ", path + "/www"
                            copytree(config["absolut_root_path"] + "/www/", path + "/www", ignore=ignore_patterns('sd', 'flash', 'examples', 'usbFlash'))
                            print "OK"
                else:
                    try:
                        os.remove(path + "/www")
                    except:
                        print "Symlink don't exist. Will create new one for this project"
                    os.symlink(config["absolut_root_path"] + "/www/", path + "/www")

                # copy all files from directory boilerplate to destination
                mypath = "www/libs/weio/boilerPlate/"
                onlyfiles = [ f for f in os.listdir(mypath) if isfile(join(mypath,f)) ]
                for f in onlyfiles:
                    copyfile(mypath+f, path +"/"+f)

                print "LASTOPENED new project", path
                config["last_opened_project"] = path
                weioConfig.saveConfiguration(config);

                data['status'] = "New project created"
                data['path'] = path
                self.broadcast(clients, json.dumps(data))
        else:
            print "BAD PATHNAME"
开发者ID:Capt-Cpt,项目名称:weio,代码行数:59,代码来源:dashboardHandler.py

示例8: sendUserData

    def sendUserData(self,rq):
        data = {}
        # get configuration from file
        config = weioConfig.getConfiguration()
        data['requested'] = rq['request']

        data['name'] = config["user"]
        self.broadcast(clients, json.dumps(data))
开发者ID:Capt-Cpt,项目名称:weio,代码行数:8,代码来源:dashboardHandler.py

示例9: checkPermission

 def checkPermission(self, password, username):
     confFile = weioConfig.getConfiguration()
     validPass = confFile['password']
     #if username == "admin" and password == "admin":
     #    return True
     if password == validPass:
         return True
     return False
开发者ID:WRTIOT,项目名称:weio,代码行数:8,代码来源:loginHandler.py

示例10: post

    def post(self):
        confFile = weioConfig.getConfiguration()
        fullName = self.get_argument("fullName", "")
        passwd = self.get_argument("password", "")
        boardname = self.get_argument("boardname", "")

        # This is two letters country code to be used to setup wifi region
        countryCode = self.get_argument("countryCode", "")

        print "************ ", fullName, passwd, boardname, countryCode

        data = {}
        # OK now is time to setup username and password
        confFile['user'] = fullName
        weioConfig.saveConfiguration(confFile)

        output = "OK PASSWD"
        #echo -e "weio\nweio" | passwd

        # ATTENTION, DON'T MESS WITH THIS STUFF ON YOUR LOCAL COMPUTER
        # First protection is mips detection, second is your own OS
        # who hopefully needs sudo to change passwd on the local machine
        if (platform.machine() == 'mips'):

            # Change root password
            command = "sh scripts/change_root_pswd.sh " + passwd
            print "EXEC : " + command

            try:
                subprocess.call(command, shell=True)
                firstTimeSwitch = "NO"
                confFile['first_time_run']=firstTimeSwitch
            except:
                output = "ERR_CMD PASSWD"
                print output

            # Change avahi name
            command = "sh scripts/change_boardname.sh " + boardname
            print "EXEC : " + command

            try:
                subprocess.call(command, shell=True)
            except:
                output = "ERR_CMD BRDNAME"

        else:
            # On PC
            firstTimeSwitch = "NO"
            confFile['first_time_run']=firstTimeSwitch
        
        # Save new password in the config file
        confFile['password'] = passwd

        # Write in config file
        weioConfig.saveConfiguration(confFile)

        self.set_secure_cookie("user", tornado.escape.json_encode("weio"))
        self.redirect(self.get_argument("next", u"/"))
开发者ID:criptonauta,项目名称:weio,代码行数:58,代码来源:signinHandler.py

示例11: downloadUpdate

    def downloadUpdate(self, data):
        config = weioConfig.getConfiguration()

        # ok now save binary in /tmp (folder in RAM)
        print "downloaded"

        fileToStoreUpdate = ""
        if (platform.machine()=="mips") :
            fileToStoreUpdate = "/tmp/weioUpdate.tar.gz"
            pathToDecompressUpdate = "/tmp"
        else :
            fileToStoreUpdate = "./weioUpdate.tar.gz"
            pathToDecompressUpdate = "./"

        if not(self.downloadUpdateLink is None):

            sw = functools.partial(self.sizeWatcher, fileToStoreUpdate, self.updateDownloadSize)
            sizeCheckerCallback = ioloop.PeriodicCallback(sw, 500)
            sizeCheckerCallback.start()
            self.startDownload(self.downloadUpdateLink, fileToStoreUpdate)
            sizeCheckerCallback.stop()

        # Check is file size is the same as on the server
        sizeOnDisk = os.path.getsize(fileToStoreUpdate)
        print "comparing sizes", sizeOnDisk, self.updateDownloadSize
        if (sizeOnDisk == self.updateDownloadSize):
            # OK
            print "File size is OK"
            self.progressInfo("50%", "File size OK")
            print "Bundle decompressing"
            tar = tarfile.open(fileToStoreUpdate)
            tar.extractall(pathToDecompressUpdate)
            tar.close()
            print "Bundle decompressed"
            #self.progressInfo("80%", "WeIO Bundle decompressed")

            # kill arhive that we don't need anymore to free RAM
            os.remove(fileToStoreUpdate)
            global currentWeioConfigurator
            print "Setting kill flag to YES in current config.weio"
            print "Now I'm ready to exit Tornado and install new version"
            config["kill_flag"] = "YES"
            weioConfig.saveConfiguration(config)
            #self.progressInfo("81%", "WeIO installing")
            # Now quit Tornado and leave script to do his job
            ioloop.IOLoop.instance().stop()
            exit()

        else :
            print "MD5 checksum is not OK, retrying..."
            if (self.downloadTries<2):
                self.progressInfo("5%", "Downloading Bundle again, MD5 checkum was not correct")
                self.downloadUpdate(None)
            else:
                print "Something went wrong. Check Internet connection and try again later"
                self.progressInfo("0%", "Something went wrong. Check Internet connection and try again later")

            self.downloadTries+=1
开发者ID:ukicar,项目名称:weio-1,代码行数:58,代码来源:updaterHandler.py

示例12: duplicateProject

    def duplicateProject(self, rq):
        config = weioConfig.getConfiguration()

        print "DUPLICATE",rq

        storage = rq['storageUnit']

        path = "www/" + rq['storageUnit'] + "/" + rq['path']

        print "DUPLICATE PROJECT", path
        data = {}
        if (len(path)>0):
            if (storage != "sd" and storage != "usbFlash"):
                # Destroy symlink
                if os.path.islink(config["last_opened_project"]+"/www"):
                    os.remove(config["last_opened_project"]+"/www")
                else:
                    shutil.rmtree(config["last_opened_project"]+"/www")
                # copy all files
                try:
                    copytree(config["last_opened_project"], path)
                except:
                    print sys.exc_info()[0]
            else:
                if os.path.isdir("www/"+rq['storageUnit']):
                    try: 
                        copytree(config["last_opened_project"], path, ignore=ignore_patterns('www'))
                    except:
                        print sys.exc_info()[0]

            if (storage != "sd" and storage != "usbFlash"):
                # Recreate symlink
                os.symlink(config["absolut_root_path"] + "/www/", path + "/www")
            else:
                if not (os.path.exists(path + "/www")):
                    copytree(config["absolut_root_path"] + "/www/", path + "/www", ignore=ignore_patterns('sd', 'flash', 'examples', 'usbFlash'))

            config["last_opened_project"] = path
            weioConfig.saveConfiguration(config)

            data['status'] = "Project duplicated"

            data['requested'] = "status"
            self.broadcast(clients, json.dumps(data))

            # now go to newely duplicated project

            data['request'] = "changeProject"
            data['data'] = rq['storageUnit'] + "/" + rq['path']

            self.changeProject(data)
        else:
            print "BAD PATHNAME"
            data['status'] = "Error duplicating project"

            data['requested'] = "status"
            self.broadcast(clients, json.dumps(data))
开发者ID:Capt-Cpt,项目名称:weio,代码行数:57,代码来源:dashboardHandler.py

示例13: sendUserPortNumber

    def sendUserPortNumber(self, rq):

        # get configuration from file
        config = weioConfig.getConfiguration()

        data = {}
        data['requested'] = rq['request']
        data['data'] = config["userAppPort"]
        # Send connection information to the client
        self.broadcast(clients, json.dumps(data))
开发者ID:WRTIOT,项目名称:weio,代码行数:10,代码来源:editorHandler.py

示例14: checkConnection

    def checkConnection(self) :
        command = "iwconfig " + self.interface
        status = weioSubprocess.shellBlocking(command)

        #print(str(status))
        # We are in STA mode, so check if we are connected
        if (status == "ERR_CMD") or "No such device" in status :
            # WiFi is DOWN
            print "Wifi is DOWN"
            self.mode = None
        # Check if wlan0 is in Master mode
        elif "Mode:Master" in status :
            print "AP Mode"
            self.mode = "ap"
            #self.essid = status.strip().startswith("ESSID:").split(':')[1]
        elif "Mode:Managed" in status :
            if "Access Point: Not-Associated" in status :
                self.mode = None
            else :
                self.mode = "sta"

        # We can not serve anything if we are not in sta or ap mode
        #print "CHECKING WIFI!"
        #if (self.mode != None):
        #   print "self.mode = " + self.mode
        #print "weioIpAddress.getLocalIpAddress() = " + weioIpAddress.getLocalIpAddress()

        if (self.mode == None):
            self.disconnectedCounter = self.disconnectedCounter + 1
        else:
            self.disconnectedCounter = 0

        config = weioConfig.getConfiguration()

        if ((self.disconnectedCounter >= 2 or (self.mode == "sta" and weioIpAddress.getLocalIpAddress() == ''))
             and config['auto_to_ap'] == "YES"):
            # Move to Master mode
            print "Trying to move to AP RESCUE mode..."
            subprocess.call("scripts/wifi_set_mode.sh rescue", shell=True)

            self.disconnectedCounter = 0

            # Restart Tornado (shell script bring it up whenever it exits)
            #cmd = "/etc/init.d/weio_run restart"
            #weioSubprocess.shellBlocking(cmd)
            print "************* EXITING ****************"
            os._exit(os.EX_OK)

        # At this point connection has been maid, and all we have to do is check ESSID
        #print "WIFI ESSID : ", status
        pat = r"(?<=ESSID:\")(.*\n?)(?=\")"
        #print "RESULT", re.findall(pat, status)[0]
        essidName = re.findall(pat, status)
        if (len(essidName)>0):
            self.essid = essidName[0]
开发者ID:Capt-Cpt,项目名称:weio,代码行数:55,代码来源:weioWifi.py

示例15: sendIp

    def sendIp(self,rq):

        # get configuration from file
        config = weioConfig.getConfiguration()

        data = {}
        ip = weioIpAddress.getLocalIpAddress()
        #publicIp = weioIpAddress.getPublicIpAddress()
        data['requested'] = rq['request']
        data['status'] = config["dns_name"] + " on " + ip
        # Send connection information to the client
        self.broadcast(clients, json.dumps(data))
开发者ID:Capt-Cpt,项目名称:weio,代码行数:12,代码来源:dashboardHandler.py


注:本文中的weioLib.weioConfig.getConfiguration函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。