示例#1
0
 def classify_query(self):
     stat = (self.query).split("|")
     self.operation = stat[0]
     if (self.operation == "select"):
         print(stat)
         query1 = Select(stat, self.database)
         query1.make_select()
示例#2
0
	def classify_query(self):
		stat = (self.query).split("|");
		self.operation = stat[0]
		if(self.operation=="select"):
			print(stat)
			query1 = Select(stat,self.database);
			query1.make_select();	
示例#3
0
 def Simulate(self, simulation_loop=1, state_value_report=True):
     for looptime in range(simulation_loop):
         R = 0
         is_end = False
         next_feature = False
         current_feature = -1
         current_label = -1
         self.Reset()
         while True:
             if is_end:
                 Update.MonteCarlo_Update(R, self.state_list,
                                          self.state_action_label_value_map)
                 break
             else:
                 next_feature = Select.MonteCarlo_Epsilon_Select(
                     self.feature_remaining, current_feature, current_label,
                     self.state_action_label_value_map)
                 Select.Erase_Feature(self.feature_remaining, next_feature)
                 self.hypo_remaining_set = Observe.Observe_Subset(
                     self.true_hypothesis, self.hypo_remaining_set,
                     next_feature)
                 Observe.Clear_Overlap(self.feature_remaining,
                                       self.hypo_remaining_set)
                 is_end = Observe.Check_End(self.hypo_remaining_set)
                 self.state_list.append(
                     (current_feature, next_feature, current_label))
                 R += -1
                 current_label = self.true_hypothesis[next_feature]
                 current_feature = next_feature
     if state_value_report:
         Report.Report_State_Value_Map(self.state_action_label_value_map)
示例#4
0
def UnionSelect(sql):
    sql = sql.lower()
    sql1 = sql.split('union select')[0]
    sql2 = sql.split('union select')[1]
    sql2 = 'select'+ sql2
    #print sql1,sql2
    res1 = Select(sql1, currentdb)
    res2 = Select(sql2, currentdb)
    # print res1
    # print res2
    # print PrettyTable
    sql = sql.lower()
    sqlItem = re.split(r'[, ]', sql)
    RemoveKong(sqlItem)
    colname = sqlItem[sqlItem.index('select')+1 : sqlItem.index('from')]
    # print colname
    # print sqlItem
    PrintTable = PrettyTable()
    PrintTable.field_names = colname
    for i in res1:
        PrintTable.add_row(i)
    for i in res2:
        if i not in res1:
            PrintTable.add_row(i)
    print 'Union Result:'
    print PrintTable
示例#5
0
def execute(sql):
    where = sp.get_where(sql)
    selects = where[1]

    query_relations = {}
    selects_for_relation = {}

    renames = sp.get_tables(sql)
    print('tables:')
    for t in renames:
        # print('loading', renames[t], '...')
        rel = data.load_pickle(renames[t])
        # rel = data.data[renames[t]]['data']
        query_relations[t] = rel
        selects_for_relation[t] = []

    for s in selects:
        ss = Select.remove_outer_parentheses(str(s))
        table_abr = ss.split('.')[0]
        selects_for_relation[table_abr].append(ss)
        print(s)

    print('\nselects and sizes:')
    for qr in query_relations:
        print('table:', qr, ', size:', len(query_relations[qr].index),
              ', selects:', selects_for_relation[qr])
    print(selects_for_relation)
    Select.perform_selections(query_relations, selects_for_relation, renames)

    print('sizes after selection:')
    for qr in query_relations:
        print('table:', qr, ', size:', len(query_relations[qr].index))
示例#6
0
def Apply_Policy_To_Random_Hypo(hypo_subset, number_features,
                                state_action_label_value_map):
    R = 0
    is_end = False
    next_feature = 0
    true_hypothesis = Generate.Get_Hypo(hypo_subset)
    hypo_remaining_set = hypo_subset
    feature_remaining_set = []
    feature_trajectory = []
    current_feature = -1
    current_label = -1
    for i in range(number_features):
        feature_remaining_set.append(i)
    while True:
        if is_end:
            break
        else:
            next_feature = Select.MonteCarlo_Select(
                feature_remaining_set, current_feature, current_label,
                state_action_label_value_map)
            Select.Erase_Feature(feature_remaining_set, next_feature)
            hypo_remaining_set = Observe.Observe_Subset(
                true_hypothesis, hypo_remaining_set, next_feature)
            Observe.Clear_Overlap(feature_remaining_set, hypo_remaining_set)
            is_end = Observe.Check_End(hypo_remaining_set)
            feature_trajectory.append(next_feature)
            current_label = true_hypothesis[next_feature]
            current_feature = next_feature
    return feature_trajectory
示例#7
0
	def classify_query(self):
		stat = (self.query).split("|");
		self.operation = stat[0]
		if(self.operation=="select"):
			query1 = Select(stat,self.database);
			query1.make_select();	

		if(stat[0]=="update"):
			if 'where' in stat:
				query2 = Update(stat,self.database);			
				query2.MakeUpdate();
			else:
				print("Invalid input 'where clause' does not exist!")
示例#8
0
    def mouseReleaseEvent(self, event, camControl, scene):
        '''Handle the mouse press event, returning an EventReport

        @param:     event       The event.
        @param:     camControl  The scene's camera control for this event.
        @param:     scene       The scene.
        @returns:   An instance of EventReport.
        '''
        result = EventReport(True)

        # if not handled, either perform selection or view manipulation
        hasCtrl, hasAlt, hasShift = getModState()
        btn = event.button()
        if (btn == LEFT_BTN and not hasAlt):
            self.selecting = False
            if (self.currPoint is None):
                # TODO: Eventually shift this to allow for a selection REGION
                selected = self.selectSingle(scene, camControl,
                                             (event.x(), event.y()))
            else:
                selected = self.selectRegion(scene, camControl, self.downPoint,
                                             self.currPoint)
                # Need to stop drawing the selection region
                result.needsRedraw = True

            if (selected):
                if (hasShift and hasCtrl):
                    # add
                    result.needsRedraw |= Select.addToGlobalSelection(
                        selected) > 0
                elif (hasShift):
                    # toggle
                    result.needsRedraw |= Select.toggleGlobalSelection(
                        selected) > 0
                elif (hasCtrl):
                    # remove
                    result.needsRedraw |= Select.removeFromGlobalSelection(
                        selected) > 0
                else:
                    # replace
                    result.needsRedraw |= Select.setGlobalSelection(
                        selected) > 0
            else:
                if (not (hasShift or hasCtrl)):
                    result.needsRedraw |= Select.clearGlobalSelection() > 0
            self.currPoint = self.downPoint = None
        if (result.needsRedraw):
            self.selectionChanged()
        return result
示例#9
0
    def selectRegion(self, scene, camControl, point0, point1):
        '''Given the scene, camera and a selection *region*, returns a set of all
        selectables which intersect the region.

        @param:     scene       The scene.
        @param:     camControl  The camera control.
        @param:     point0      The x-y coordintes of one corner of the rectangular region.
        @param:     point1      The x-y coordintes of the other corner of the rectangular region.
        @returns:   The selected object.
        '''
        x0 = min(point0[0], point1[0])
        x1 = max(point0[0], point1[0])
        y0 = min(point0[1], point1[1])
        y1 = max(point0[1], point1[1])
        glPushAttrib(GL_ENABLE_BIT)
        glDisable(GL_LIGHTING)
        glDisable(GL_TEXTURE_2D)

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()

        camControl.setSelectMatRegion(x0, y0, x1, y1)
        camControl.setGLView()

        ##        Select.start()
        ##        self.drawUIGL( Select.SelectState.SELECT )
        ##        newSelection = Select.end()
        newSelection = None

        if (newSelection == None):
            ##            Select.start()
            ##            self.draw3DGL( Select.SelectState.SELECT )
            ##            newSelection = Select.end()
            if (newSelection == None):
                Select.start()
                scene.drawTreeGL(Select.SelectState.SELECT)
                selected = Select.endSet()
        glMatrixMode(GL_PROJECTION)
        glPopMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPopMatrix()
        glPopAttrib()

        return selected
示例#10
0
def openid():
    Code = request.args.get('code')  # 获取Code
    OpenId.openid.setcode(OpenId, Code)     # 传入COde
    OpenId.openid.openid(OpenId)    # 执行获取Openid
    if not Select.openid(OpenId.openid.getopenid(OpenId)):  # 查询数据库有没有openid
        Insert.openid(OpenId.openid.getopenid(OpenId))
        OpenId.openid.mkdir(OpenId)
    return 'ok'
示例#11
0
def select():
    root = rooter("Select", False)
    root.geometry("430x180+0+0")
    Select.Frame(root, File.Read("Words/Files.txt"), "Select").mainloop()

    #Clears ups the output file to avoid bugs with Create/Select

    global file
    with open("Output.txt", "r") as f:
        if (f.read().count(" ") > 0):
            with open("Output.txt", "w") as f:
                f.write(file.split(".")[0])
    f.close()
示例#12
0
	def classify_query(self):
		stat = (self.query).split("|");
		self.operation = stat[0]
		if(self.operation=="select"):
			print(stat)
			q1=Semantic(stat,"select")
			check=q1.select_tree()
			
		
			if check == True:
				tblnames=q1.returnTblname()
				targetPrint=q1.returnTargetPrint()
				join_clause=q1.returnJoinClause()
				where_operation=q1.returnWhere()
				query1 = Select(stat,self.database,targetPrint,tblnames,join_clause,where_operation)
				query1.make_select()
			else:
				return False	

		if(self.operation=="update"):
			print(stat)
			q1=Semantic(stat,"update")
			check=q1.select_tree()

			if check == True:
				targetColumns=q1.returnColumns()
				newValues=q1.returnNewValues()
				tblnames=q1.returnTblname()
				where_operation=q1.returnWhere()
				query1 = Update(stat,self.database,targetColumns,tblnames,newValues,where_operation)
				self.database=query1.perform_update()
						
					
		
		if(self.operation=="delete"):	
			q1=Semantic(stat,"delete")
			check=q1.select_tree()

			if check==True:
				tblname = q1.returnTblname()
				where_operation=q1.returnWhere()
				query1=Delete(stat,self.database,tblname,where_operation)
				self.database=query1.perform_delete()				
示例#13
0
def ViewCreate(currentdb, viewname, sql):
    wb = load_workbook('data/view.xlsx')
    try:
        sheet = wb[viewname]
    except:
        sheet = wb.create_sheet()
        sheet.title = viewname
    sql = sql.lower()
    sqlItem = re.split(r'[, ]', sql)
    RemoveKong(sqlItem)
    headers = sqlItem[sqlItem.index('select') + 1:sqlItem.index('from')]
    #print headers
    viewtableItem = Select(sql, currentdb)
    for i in xrange(1, len(headers) + 1):
        sheet.cell(1, i).value = headers[i - 1]
        #print sheet.cell(1, i).value

    for i in xrange(2, len(viewtableItem) + 1):
        for j in xrange(1, len(headers) + 1):
            sheet.cell(i, j).value = viewtableItem[i - 2][j - 1]
    wb.save('data/view.xlsx')
    print '%s View has been create.' % viewname
示例#14
0
    def selectSingle(self, scene, camControl, selectPoint, pickSize=5):
        '''Given the scene, camera and a selection point in screen space,
        performs selection and returns the single front-most selectable under the mouse.

        @param:     scene       The scene.
        @param:     camControl  The camera control.
        @param:     selectPoint The screen space point at which selection is to be done.
        @param:     pickSize        The size of the selection box around the selectPoint.
        @returns:   The selected object.
        '''
        glPushAttrib(GL_ENABLE_BIT)
        glDisable(GL_LIGHTING)
        glDisable(GL_TEXTURE_2D)

        glMatrixMode(GL_PROJECTION)
        glPushMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPushMatrix()

        camControl.setSelectMat(selectPoint, pickSize)
        camControl.setGLView()

        ##        Select.start()
        ##        self.drawUIGL( Select.SelectState.SELECT )
        ##        selected = Select.endSingle()
        selected = None

        if (selected is None):
            Select.start()
            self.draw3DGL(camControl, Select.SelectState.SELECT)
            selected = Select.endSingle()
            if (selected is None and scene is not None):
                Select.start()
                scene.drawTreeGL(Select.SelectState.SELECT)
                selected = Select.endSingle()
        glMatrixMode(GL_PROJECTION)
        glPopMatrix()
        glMatrixMode(GL_MODELVIEW)
        glPopMatrix()
        glPopAttrib()

        return selected
示例#15
0
     # Display configuration dialog.
     ThisDisplay.CurrentTab["CONFIGURE"] = Config.Config(
         ThisDisplay.ThisSurface, "CONFIGURE", "CONFIGURE")
 # If save config button is pressed.
 elif ButtonGadgit["BUTTON"] == "SAVE_CONFIG":
     ThisDisplay.CurrentTab.pop("CONFIGURE", None)
     ApplyConfig()
 elif ButtonGadgit["BUTTON"] == "SELECT_FONT":
     # Remember which gadgit the select is for.
     SelectGadgit = ButtonGadgit["GADGIT"]
     # Get a list of mono space font names.
     SelectText = ThisDisplay.CurrentTab[
         "CONFIGURE"].GetFontNameList()
     # Display a font name selection dialog.
     ThisDisplay.CurrentTab["SELECT"] = Select.Select(
         ThisDisplay.ThisSurface, "SELECT_FONT_NAME",
         SelectText)
 elif ButtonGadgit["BUTTON"] == "SELECT_VEHICLE":
     # Remember which gadgit the select is for.
     SelectGadgit = ButtonGadgit["GADGIT"]
     # Get a list of vehicle trouble code file names.
     SelectText = ThisDisplay.CurrentTab[
         "CONFIGURE"].GetVehicleNameList()
     # Display a font name selection dialog.
     ThisDisplay.CurrentTab["SELECT"] = Select.Select(
         ThisDisplay.ThisSurface, "SELECT_VEHICLE_NAME",
         SelectText)
 elif ButtonGadgit["BUTTON"] == "SELECT_SERIAL_PORT":
     # Remember which gadgit the select is for.
     SelectGadgit = ButtonGadgit["GADGIT"]
     # Get a list of vehicle trouble code file names.
示例#16
0
def siql(cadena, identificadorNombre, identificadorDatos, identificadorEstruc,
         memoriaActual, estrucActual, tokens):
    estado = 0
    palabra = ""
    archivos = []
    for i in cadena:
        if estado == 0:
            if palabra == "script":
                tokens.append("tk: SCRIPT (Palabra Reservada)")
                palabra = ""
                estado = 1
            elif i != " ":
                palabra = palabra + i.lower()
        elif estado == 1:
            if i != " " or i != ",":
                palabra = palabra + i
            elif i == " " or palabra == ",":
                if i == ",":
                    tokens.append("tk: " + palabra + " (Archivo)")
                    tokens.append("tk: ',' (Separador)")
                archivos.append(palabra)
                palabra = ""
    archivos.append(palabra)
    tokens.append("tk: " + palabra + " (Archivo)")
    archivos2 = []
    palabra = ""
    for u in archivos:
        comandos = []
        try:
            with open(u, 'r') as arch:
                data = arch.read()
                arch.close()
                for i in data:
                    if i == ";" or i == "\n" or i == "":
                        comandos.append(palabra)
                        palabra = ""
                    else:
                        palabra = palabra + i
            if comandos is not None:
                archivos2.append(comandos)
        except (OSError, IOError):
            print("Estructura no definida")
            print("------------------------------------")

    for i in archivos2:
        for u in i:
            comando = inicio(u.lower())
            if comando == "createset":
                createset(u.lower(), identificadorNombre, identificadorDatos,
                          identificadorEstruc, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "loadinto":
                loadinto(u.lower(), identificadorNombre, identificadorDatos,
                         identificadorEstruc, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "useset":
                memoria = usesetD(u.lower(), identificadorNombre,
                                  identificadorDatos, tokens)
                estructura = usesetE(u.lower(), identificadorNombre,
                                     identificadorEstruc)
                if memoria != "":
                    memoriaActual = memoria
                    estrucActual = estructura
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "select":
                Select.select(u, memoriaActual, estrucActual, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "listattributes":
                if memoriaActual is not None:
                    for z in memoriaActual:
                        print(z)
                else:
                    print(
                        "No se a cargado ninguna memoria creada, usar comando -use set-"
                    )
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "printin":
                printin(u.lower(), tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "max":
                maximo(u.lower(), memoriaActual, estrucActual, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "min":
                minimo(u, memoriaActual, estrucActual, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "sum":
                sum(u, memoriaActual, estrucActual, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "count":
                count(u.lower(), memoriaActual, estrucActual, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "reportto":
                Reporte.reportar(u, memoriaActual, estrucActual, tokens)
                print(
                    "------------------------------------------------------------"
                )

            elif comando == "reporttokens":
                for z in tokens:
                    print(z)
                print(
                    "------------------------------------------------------------"
                )
    MenuPrincipal.cargaA(identificadorNombre, identificadorDatos,
                         identificadorEstruc, memoriaActual, estrucActual,
                         tokens)
示例#17
0
browser.get(('http://egovernance/Egovwebapp/home.aspx'))



username = browser.find_element_by_id('txtUserName')
username.send_keys(usernameStr)

password = browser.find_element_by_id('txtPassword')

password.send_keys(passwordStr)

signInButton = browser.find_element_by_id('ibtnLogin')
signInButton.click()
time.sleep(3)
body=browser.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 't')
browser.get('http://egovernance/Egovwebapp/SIS/frmFacultyFeedback.aspx')
#if not(signInButton ==''):
    #browser2 = webdriver.Chrome()
    #browser.get(('http://egovernance/Egovwebapp/frmUserProfile.aspx'))
    #egov = browser.find_element_by_name("dlAppList$ctl00$ctl00")
    #egov.click()
    #driver.send_keys(Keys.CONTROL + 'T')
    #elem = browser.find_element_by_xpath("/html/body/div[2]/div[4]/div/a") #href link
    #time.sleep(2) 
    #elem.send_keys(Keys.CONTROL + Keys.RETURN + "2")
drp=Select(browser.find_element_by_class_name('FormDL'))
drp.select_by_value("5619")

    
    
# Create a new plot: plot
plot = figure()

# Add circles to the plot
plot.circle('x', 'y', source=source)

# Define a callback function: update_plot
def update_plot(attr, old, new):
    # If the new Selection is 'female_literacy', update 'y' to female_literacy
    if new == 'female_literacy': 
        source.data = {
            'x' : fertility,
            'y' : female_literacy
        }
    # Else, update 'y' to population
    else:
        source.data = {
            'x' : fertility,
            'y' : population
        }

# Create a dropdown Select widget: select    
select = Select(title="distribution", options=['female_literacy', 'population'], value='female_literacy')

# Attach the update_plot callback to the 'value' property of select
select.on_change('value', update_plot)

# Create layout and add to current document
layout = row(select, plot)
curdoc().add_root(layout)
    def __init__(self, tables, joins, selects, test=False):
        assert isinstance(tables, dict) and all(
            isinstance(t[0], str) and isinstance(t[1], str)
            for t in tables.items())
        assert isinstance(joins, list) and all(
            isinstance(j, str) for j in joins)
        assert isinstance(selects, list) and all(
            isinstance(s, str) for s in selects)

        selects_for_relation = defaultdict(list)
        for s in selects:
            print('Building Select:', s)
            ss = Select.remove_outer_parentheses(str(s))
            table_abr = ss.split('.')[0]
            selects_for_relation[table_abr].append(ss)

        print('\nRelations:')
        self.V = dict()
        for (k, v) in tables.items():
            # Load the data
            print('Loading', (k, v))
            if test:
                print('THIS IS A TEST!!!')
                df = pd.DataFrame()
            else:
                df = DataLoader.load_pickle(v)
                df.columns = [k + '_' + c for c in DataLoader.columns[v]]
                print(df.columns)
                # Perform selections on the data
                for s in selects_for_relation[k]:
                    print(s)
                    df = Select.perform_selection(df, s)
            df.relation_name = k

            # Create a relation node
            r = Relation(df)
            self.V[k] = r

        # Create the predicate edges
        # self.E = {v: set() for v in self.V}
        joins = [j.replace(' ', '').split('=') for j in joins]
        joins = [(t1.split('.'), t2.split('.')) for t1, t2 in joins]
        for t1, t2 in joins:
            assert t1[0] in self.V.keys() and t2[0] in self.V.keys()

            # Add edges between them
            r1, r2 = self.V[t1[0]], self.V[t2[0]]
            assert isinstance(r1, Relation) and isinstance(r2, Relation)

            # set r2 as neighbor of r1
            if r2 in r1.neighbors.keys():
                r1.neighbors[r2].add((t1[1], t2[1]))
                # self.E[r1].add(r2)
            else:
                r1.neighbors[r2] = {(t1[1], t2[1])}
                # self.E[r1] = {r2}

            # set r1 as neighbor of r2
            if r1 in r2.neighbors.keys():
                r2.neighbors[r1].add((t2[1], t1[1]))
                # self.E[r2].add(r1)
            else:
                r2.neighbors[r1] = {(t2[1], t1[1])}
                # self.E[r2] = {r1}

        # Print all the neighbors
        print('\nNeighbors:')
        for k, v in self.V.items():
            print(k, ':', v.neighbors)