コード例 #1
0
def camera_wget_download(self, parameterLine, fileName=None):

    STYLE = 1

    fileName = fileName if fileName is not None else STYLE is 2
    #fileName = str(fileName) #because the scheme above initializes 'fileName' as a boolean

    if STYLE is 1:
        try:
            command = "wget 'http://" + self.HOST + "/parsedit.php?immediate" + parameterLine + "' -O " + str(
                fileName) + ".xml"
            #the 'str(fileName)' is done because the scheme above initializes 'fileName' as a boolean
            print_DEBUG(self, "\ncommand line is:" + command + "\n")  #debug
            subprocess.call(command, shell=True)
            return 1
        except:
            return -1
    else:
        try:
            command = "wget --delete-after 'http://" + self.HOST + "/parsedit.php?immediate" + parameterLine + "'"
            print_DEBUG(self, "\ncommand line is:" + command + "\n")  #debug
            subprocess.call(command, shell=True)
            return 1
        except:
            return -1
コード例 #2
0
ファイル: tools.py プロジェクト: BielBdeLuna/ElpAPI
def XML_2_dict(file, dic):
    tree = ElTree.parse(file)
    root = tree.getroot()

    for child in tree.iter():
        for c in child:
            print_DEBUG(self,"c.tag is: " + c.tag + " and c.text is: " + c.text)
            dic[c.tag] = c.text
コード例 #3
0
def XML_2_dict(file, dic):
    tree = ElTree.parse(file)
    root = tree.getroot()

    for child in tree.iter():
        for c in child:
            print_DEBUG(self,
                        "c.tag is: " + c.tag + " and c.text is: " + c.text)
            dic[c.tag] = c.text
コード例 #4
0
def get_list_parameters(self,parameters,destinePath,fileName):
    self.DWN_STATE = True
    os.chdir(destinePath)
    parmLine="&"
    i = 0
    maxLength = len(parameters)
    for i in range (maxLength):
        parmLine = parmLine + parameters[i] + "&"
        i = i + 1
    print_DEBUG(self,"parmLine is:" + parmLine) #debug
    camera_wget_download(self,parmLine,fileName)
    self.DWN_STATE = False
コード例 #5
0
def get_dictionary_parameters(self,parameters,destinePath,fileName):
    self.DWN_STATE = True
    os.chdir(destinePath)
    keyList = parameters.keys() # values get ignored and only a key list remains, in order to gather new values
    parmLine="&"
    i = 0
    maxLength = len(keyList)
    for i in range (maxLength):
        parmLine = parmLine + keyList[i] + "&"
        i = i + 1
    print_DEBUG(self,"parmLine is:" + parmLine) #debug
    camera_wget_download(self,parmLine,fileName)
    self.DWN_STATE = False
コード例 #6
0
ファイル: multicam.py プロジェクト: BielBdeLuna/ElpAPI
def download_settings(cam, parmameters):
#def download_settings(cam, parmameters, settDic):
    cam.get_parameters(parmameters,DESTPATH,"camera_settings") 
    #download the camera settings using the dictionary as a reference.

    try:
        tree = ElTree.parse(os.path.join(DESTPATH,"camera_settings.xml"))
        root = tree.getroot()
        print_DEBUG(camera,"'tree' is:" + str(tree)) #debug
        print_DEBUG(camera,"'root' is" + str(root)) #debug
    except:
        print_ERROR(camera,"Something went wrong while parsing 'camera_settings.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                #settDic[c.tag] = c.text
                cam.implant_camera_setting(c.tag, c.text)
コード例 #7
0
ファイル: tools.py プロジェクト: BielBdeLuna/ElpAPI
def camera_wget_download (self, parameterLine,fileName=None):

    STYLE = 1

    fileName = fileName if fileName is not None else STYLE is 2
    #fileName = str(fileName) #because the scheme above initializes 'fileName' as a boolean

    if STYLE is 1:
        try:
            command = "wget 'http://"+self.HOST+"/parsedit.php?immediate"+parameterLine+"' -O "+str(fileName)+".xml"
            #the 'str(fileName)' is done because the scheme above initializes 'fileName' as a boolean
            print_DEBUG(self,"\ncommand line is:" + command + "\n") #debug
            subprocess.call(command,shell=True)
            return 1
        except:
            return -1
    else:
        try:
            command = "wget --delete-after 'http://"+self.HOST+"/parsedit.php?immediate"+parameterLine+"'"
            print_DEBUG(self,"\ncommand line is:" + command + "\n") #debug
            subprocess.call(command,shell=True)
            return 1
        except:
            return -1
コード例 #8
0
ファイル: ElpAPI.py プロジェクト: BielBdeLuna/ElpAPI
    def set_default_settings(self, XMLparmFile):

        import xml.etree.ElementTree as ElTree

        changes = False
        error = False
        currentParmsDic = {}
        sendParmsDic = {}
        maxLengthWan = 0
        maxLengthCam = 0

        self.AUTO_CONFG = True

        

        try:
            print_DEBUG(self,"obre el 'try' amb XMLparmFile:" + XMLparmFile) #debug
            tree = ElTree.parse(XMLparmFile)
            print_DEBUG(self,"crea el 'tree'") #debug
            root = tree.getroot()
            rint_DEBUG(self,"pren l'arrel") #debug
            print_DEBUG(self,"'tree' is:" + str(tree)) #debug
            print_DEBUG(self,"'root' is" + str(root)) #debug
        except:
            print_ERROR(self,"Something went wrong while parsing " + XMLparmFile)
            error = True
        else:
            for child in tree.iter():
                for c in child:
                    self.DIC_SETTINGS[c.tag] = c.text

        keyListWan = self.DIC_SETTINGS.keys()

        if error is not True:

            self.get_parameters(self.DIC_SETTINGS,self.PATH,"camera_settings")

            try:
                tree = ElTree.parse(os.path.join(DESTPATH,"camera_settings.xml"))
                root = tree.getroot()
                print_DEBUG(self,"'tree' is:" + str(tree)) #debug
                print_DEBUG(self,"'root' is" + str(root)) #debug
            except:
                print_ERROR(self,"Something went wrong while parsing 'camera_settings.xml'")
                error = True
            else:
                for child in tree.iter():
                    for c in child:
                        currentParmsDic[c.tag] = c.text

            keyListCam = currentParmsDic.keys()

        if error is not True:

            wanVal = ""
            camVal = ""
            w = 0
            maxLengthWan = len(keyListWan)
            print_DEBUG(self,"'maxLengthWan' is: " + str(maxLengthWan)) #debug
            maxLengthCam = len(keyListCam)
            print_DEBUG(self,"'maxLengthCam' is: " + str(maxLengthCam)) #debug
            for w in range(maxLengthWan):
                wanVal = keyListWan[w]
                c = 0
                for c in range(maxLengthCam):
                    camVal = keyListCam[c]
                    if (wanVal == camVal):
                        if (self.DIC_SETTINGS[wanVal] == currentParmsDic[camVal]):
                            print_DEBUG(self,wanVal + " is " + self.DIC_SETTINGS[wanVal] + " on both dictionaries")
                            break
                        else:
                            #TODO add a pooliong system, which will allow multi-threading
                            sendParmsDic[wanVal] = self.DIC_SETTINGS[wanVal]
                            changes = True
                    c = c + 1
                w = w + 1

        else:
            print_ERROR(self,"The process failed and will end unsuccessfully")
            return

        if changes:
            set_parameters(sendParmsDic)
            print_CASUAL(self,"All new values uploaded to the camera")
        else:
            print_CASUAL(self,"No values uploaded to the camera")

        #set_parameters(self.DIC_SETTINGS)
    
        if self.DIC_SETTINGS["AUTOEXP_ON"] == 1:
            self.AUTO_EXP_STATE = False
        else:
            self.AUTO_EXP_STATE = True

        if self.DIC_SETTINGS["WB_EN"] == 1:
            self.AUTO_WB_STATE = False
        else:
            self.AUTO_WB_STATE = True

        self.AUTO_CONFG = False
コード例 #9
0
ファイル: multicam.py プロジェクト: BielBdeLuna/ElpAPI
def setupCamera_1():
    changes = False
    error = False
    wantedParmsDic = {}
    cameraParmsDic = {}
    sendParmsDic = {}
    maxLengthWan = 0
    maxLengthCam = 0

    try:
        camera1
    except NameError:
        camera1 = ElpAPI.core(HOST1) #creates camera only if it doesn't exists before
    else:
        print_CASUAL(camera1,"'camera1' object already created")
    
    try:
        tree = ElTree.parse(os.path.join(DESTPATH,"wanted_settings1.xml"))
        root = tree.getroot()
    except:
        print_ERROR(camera1,"Something went wrong while parsing 'wanted_settings.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                wantedParmsDic[c.tag] = c.text
        #created a dictionary from known sources.
        keyListWan = wantedParmsDic.keys()

    camera1.get_parameters(wantedParmsDic,DESTPATH,"camera_settings1") 
    #download the camera settings using the dictionary as a reference.
    try:
        tree = ElTree.parse(os.path.join(DESTPATH,"camera_settings1.xml"))
        root = tree.getroot()
        print_DEBUG(camera1,"'tree' is:" + str(tree)) #debug
        print_DEBUG(camera1,"'root' is" + str(root)) #debug
    except:
        print_ERROR(camera1,"Something went wrong while parsing 'camera_settings1.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                cameraParmsDic[c.tag] = c.text
                camera1.implant_camera_setting(c.tag, c.text)
        #created a new dictionary with the settings the camera is using.7

        #download_settings(camera, wantedParmsDic, cameraParmsDic)
        #download_settings(camera1, wantedParmsDic)
        keyListCam = cameraParmsDic.keys()
        #keyListCam = camera.DIC_SETTINGS.keys()
        #keyListCam = camera1.gather_camera_settings()


    if error is not True: 
        
        wanVal = ""
        camVal = ""
        w = 0
        maxLengthWan = len(keyListWan)
        print_DEBUG(camera1,"'maxLengthWan' is: " + str(maxLengthWan)) #debug
        maxLengthCam = len(keyListCam)
        print_DEBUG(camera1,"'maxLengthCam' is: " + str(maxLengthCam)) #debug
        for w in range(maxLengthWan):
            wanVal = keyListWan[w]
            c = 0
            for c in range(maxLengthCam):
                camVal = keyListCam[c]
                if (wanVal == camVal):
                    if (wantedParmsDic[wanVal] == cameraParmsDic[camVal]):
                        print_DEBUG(camera1,wanVal + " is " + wantedParmsDic[wanVal] + " on both dictionaries")
                        break
                    else:
                        #TODO add a pooliong system, which will allow multi-threading
                        sendParmsDic[wanVal] = wantedParmsDic[wanVal]
                        changes = True
                c = c + 1
            w = w + 1
    else:
        print_ERROR(camera1,"The process failed and will end unsuccessfully")
        return

    if changes:
        camera1.set_parameters(sendParmsDic)
        print_CASUAL(camera1,"All new values uploaded to the camera")
    else:
        print_CASUAL(camera1,"No values uploaded to the camera")
コード例 #10
0
ファイル: ElpAPI.py プロジェクト: BielBdeLuna/ElpAPI
    def set_default_settings(self, XMLparmFile):

        import xml.etree.ElementTree as ElTree

        changes = False
        error = False
        currentParmsDic = {}
        sendParmsDic = {}
        maxLengthWan = 0
        maxLengthCam = 0

        self.AUTO_CONFG = True

        try:
            print_DEBUG(self,
                        "obre el 'try' amb XMLparmFile:" + XMLparmFile)  #debug
            tree = ElTree.parse(XMLparmFile)
            print_DEBUG(self, "crea el 'tree'")  #debug
            root = tree.getroot()
            rint_DEBUG(self, "pren l'arrel")  #debug
            print_DEBUG(self, "'tree' is:" + str(tree))  #debug
            print_DEBUG(self, "'root' is" + str(root))  #debug
        except:
            print_ERROR(self,
                        "Something went wrong while parsing " + XMLparmFile)
            error = True
        else:
            for child in tree.iter():
                for c in child:
                    self.DIC_SETTINGS[c.tag] = c.text

        keyListWan = self.DIC_SETTINGS.keys()

        if error is not True:

            self.get_parameters(self.DIC_SETTINGS, self.PATH,
                                "camera_settings")

            try:
                tree = ElTree.parse(
                    os.path.join(DESTPATH, "camera_settings.xml"))
                root = tree.getroot()
                print_DEBUG(self, "'tree' is:" + str(tree))  #debug
                print_DEBUG(self, "'root' is" + str(root))  #debug
            except:
                print_ERROR(
                    self,
                    "Something went wrong while parsing 'camera_settings.xml'")
                error = True
            else:
                for child in tree.iter():
                    for c in child:
                        currentParmsDic[c.tag] = c.text

            keyListCam = currentParmsDic.keys()

        if error is not True:

            wanVal = ""
            camVal = ""
            w = 0
            maxLengthWan = len(keyListWan)
            print_DEBUG(self,
                        "'maxLengthWan' is: " + str(maxLengthWan))  #debug
            maxLengthCam = len(keyListCam)
            print_DEBUG(self,
                        "'maxLengthCam' is: " + str(maxLengthCam))  #debug
            for w in range(maxLengthWan):
                wanVal = keyListWan[w]
                c = 0
                for c in range(maxLengthCam):
                    camVal = keyListCam[c]
                    if (wanVal == camVal):
                        if (self.DIC_SETTINGS[wanVal] ==
                                currentParmsDic[camVal]):
                            print_DEBUG(
                                self,
                                wanVal + " is " + self.DIC_SETTINGS[wanVal] +
                                " on both dictionaries")
                            break
                        else:
                            #TODO add a pooliong system, which will allow multi-threading
                            sendParmsDic[wanVal] = self.DIC_SETTINGS[wanVal]
                            changes = True
                    c = c + 1
                w = w + 1

        else:
            print_ERROR(self, "The process failed and will end unsuccessfully")
            return

        if changes:
            set_parameters(sendParmsDic)
            print_CASUAL(self, "All new values uploaded to the camera")
        else:
            print_CASUAL(self, "No values uploaded to the camera")

        #set_parameters(self.DIC_SETTINGS)

        if self.DIC_SETTINGS["AUTOEXP_ON"] == 1:
            self.AUTO_EXP_STATE = False
        else:
            self.AUTO_EXP_STATE = True

        if self.DIC_SETTINGS["WB_EN"] == 1:
            self.AUTO_WB_STATE = False
        else:
            self.AUTO_WB_STATE = True

        self.AUTO_CONFG = False
コード例 #11
0
def setupCamera():
    changes = False
    error = False
    wantedParmsDic = {}
    cameraParmsDic = {}
    sendParmsDic = {}
    maxLengthWan = 0
    maxLengthCam = 0

    #autoKillSwitch.go() #TODO all this stuff is reserverd for the future
    #autoResolution.go() #TODO the same above
    #autoColourt.go() #TODO add a colour selection system, the same above
    try:
        camera
    except NameError:
        camera = ElpAPI.core(
            HOST)  #creates camera only if it doesn't exists before
    else:
        print_CASUAL(camera, "'camera' object already created")

    try:
        tree = ElTree.parse(os.path.join(DESTPATH, "wanted_settings.xml"))
        root = tree.getroot()
    except:
        print_ERROR(
            camera, "Something went wrong while parsing 'wanted_settings.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                wantedParmsDic[c.tag] = c.text
        #created a dictionary from known sources.
        keyListWan = wantedParmsDic.keys()

    camera.get_parameters(wantedParmsDic, DESTPATH, "camera_settings")
    #download the camera settings using the dictionary as a reference.
    try:
        tree = ElTree.parse(os.path.join(DESTPATH, "camera_settings.xml"))
        root = tree.getroot()
        print_DEBUG(camera, "'tree' is:" + str(tree))  #debug
        print_DEBUG(camera, "'root' is" + str(root))  #debug
    except:
        print_ERROR(
            camera, "Something went wrong while parsing 'camera_settings.xml'")
        error = True
    else:
        for child in tree.iter():
            for c in child:
                cameraParmsDic[c.tag] = c.text
        #created a new dictionary with the settings the camera is using.
        keyListCam = cameraParmsDic.keys()

    if error is not True:

        wanVal = ""
        camVal = ""
        w = 0
        maxLengthWan = len(keyListWan)
        print_DEBUG(camera, "'maxLengthWan' is: " + str(maxLengthWan))  #debug
        maxLengthCam = len(keyListCam)
        print_DEBUG(camera, "'maxLengthCam' is: " + str(maxLengthCam))  #debug
        for w in range(maxLengthWan):
            wanVal = keyListWan[w]
            c = 0
            for c in range(maxLengthCam):
                camVal = keyListCam[c]
                if (wanVal == camVal):
                    if (wantedParmsDic[wanVal] == cameraParmsDic[camVal]):
                        print_DEBUG(
                            camera, wanVal + " is " + wantedParmsDic[wanVal] +
                            " on both dictionaries")
                        break
                    else:
                        #TODO add a pooliong system, which will allow multi-threading
                        sendParmsDic[wanVal] = wantedParmsDic[wanVal]
                        changes = True
                c = c + 1
            w = w + 1
    else:
        print_ERROR(camera, "The process failed and will end unsuccessfully")
        return

    if changes:
        camera.set_parameters(sendParmsDic)
        print_CASUAL(camera, "All new values uploaded to the camera")
    else:
        print_CASUAL(camera, "No values uploaded to the camera")