def globalInfoTwo(): con=displayConnection() listinfo=[] index=[] counter=0 for i in range(len(con)): output=globalInfoZero(con[i]) output=output[0] output=output.split(',') listinfo.append(output) return listinfo
def globalInofslice(): f = globalInof() output = displayConnection() for i in range(len(f)): print(f[i])
def currentlyActiveConnectionNow(): output = displayConnection() list = [] list.append(output[0]) return list[0]
def globalInfo(): output=displayConnection() output.pop() turn=0 for j in output: cm1 ='nmcli connection show {} | grep -F connection.id: > /tmp/info-{}-'.format(j,output.index(j)) cm2='nmcli connection show {} | grep -F connection.type: >> /tmp/info-{}-'.format(j,output.index(j)) cm3 = 'nmcli connection show {} | grep -F GENERAL.DEVICES: >> /tmp/info-{}-'.format(j, output.index(j)) cm4 = 'nmcli connection show {} | grep -F connection.autoconnect: >> /tmp/info-{}-'.format(j, output.index(j)) cm6='' if showIpMethod(j)=='auto': cm6='nmcli connection show {}| grep -F IP4.ADDRESS[1]: >> /tmp/info-{}-'.format(j,output.index(j)) else: cm6='nmcli connection show {}| grep -F ipv4.addresses: >> /tmp/info-{}-'.format(j,output.index(j)) try: os.system(cm1) os.system(cm2) os.system(cm3) os.system(cm4) #os.system(cm6) #os.system(cm3) #os.system(cm4) except os.error: return None c=[] cs='' try: fullCommand='rm -rf /tmp/allGlobalCon' subprocess.run(fullCommand, check=True, shell=True) except subprocess.CalledProcessError: print("Error While fetching Data ") for i in range(len(displayConnection())-1): f=open(f'/tmp/info-{i}-','rt') f=f.read() all=open('/tmp/allGlobalCon','a') all.write(f) all.close() try: fullCommand = f'rm -rf /tmp/info-{i}-' subprocess.run(fullCommand, check=True, shell=True) except subprocess.CalledProcessError: print("Error While fetching Data ") f=open('/tmp/allGlobalCon','rt') f=f.read() f=f.replace('ipv4.method',',') f=f.replace('connection.type:',',') f=f.replace('IP4.ADDRESS[1]:',',') f=f.replace('ipv4.addresses',',') f=f.replace(' ','') f=f.replace(':','') f=f.replace('802-3-ethernet','ethernet') f=f.replace('802-11-wireless','wifi') f=f.replace('GENERAL.STATE',',') f=f.replace('GENERAL.DEVICES',',') f=f.replace('connection.id',':') f=f.replace('\n','') here=f here=f.replace('GENERAL.DEVICES',',') here=f.replace('connection.autoconnect',',') File=open('/tmp/listCO','w') File.write(here) File.close() list_of_users = [] with open("/tmp/listCO", mode='r') as passwd_content: passwd_content=passwd_content.read() each_user2 = passwd_content.split(":") each_user2.pop(0) for i in each_user2: k = i.split(',') list_of_users.append(k) return list_of_users
def widgets(self): self.consName = QComboBox(self) self.comboInt = QComboBox() consNames = displayConnection() consNames.pop() self.consName.addItems(consNames) interName = displayNetworkInterface() self.comboInt.addItem('no change') self.comboInt.addItems(interName) self.newconNameEdit = QLineEdit() self.operation = QComboBox() self.operation.addItem('Type') self.operation.addItem('Change Network name') self.operation.addItem('Change Network interface') self.operation.addItem('Change IP Address') self.operation.addItem('Change Subnet Mask') self.operation.addItem('Change Gateway') self.operation.addItem('Change DNS') self.operation.addItem('Change Mode Addressing') self.typeCombo = QComboBox() self.typeCombo.addItem("no change") self.typeCombo.addItem("ethernet") self.typeCombo.addItem("wifi") self.newconNameEdit = QLineEdit() self.ipEdit = QLineEdit() self.gatewayEdit = QLineEdit() self.dnsEdit = QLineEdit() self.maskListItem = QComboBox() self.maskListItem.addItem("no change") self.maskListItem.addItem(" /24: 255.255.255.0 ") self.maskListItem.addItem(" /32: 255.255.255.255 ") self.maskListItem.addItem(" /31: 255.255.255.254 ") self.maskListItem.addItem(" /30: 255.255.255.252 ") self.maskListItem.addItem(" /29: 255.255.255.248 ") self.maskListItem.addItem(" /28: 255.255.255.240 ") self.maskListItem.addItem(" /27: 255.255.255.224 ") self.maskListItem.addItem(" /26: 255.255.255.192 ") self.maskListItem.addItem(" /25: 255.255.255.128 ") self.maskListItem.addItem(" /23: 255.255.254.0 ") self.maskListItem.addItem(" /22: 255.255.252.0 ") self.maskListItem.addItem(" /21: 255.255.248.255") self.maskListItem.addItem(" /20: 255.255.255.240") self.topLayout.addRow( QLabel("Please Select Connection Name To Applay It "), self.consName) self.topLayout.addRow(QLabel(''), QLabel('')) self.topLayout.addRow(QLabel("Enter New Connection's Name"), self.newconNameEdit) self.topLayout.addRow(QLabel("Select interface"), self.comboInt) self.topLayout.addRow(QLabel("Enter New IP Address"), self.ipEdit) self.topLayout.addRow(QLabel("Enter New Subnet Mask"), self.maskListItem) self.topLayout.addRow(QLabel("Change Connection Type"), self.typeCombo) self.topLayout.addRow(QLabel("Enter New GATWAY address"), self.gatewayEdit) self.topLayout.addRow(QLabel("Change Primary DNS"), self.dnsEdit)