Example #1
0
    def tableClicked(self,itemm):
        c_path = main.current_path
        try:
            if itemm.column() == 0:
                if main.current_path == '/':
                    main.current_path += str(itemm.data())
                else:
                    main.current_path += '/'+str(itemm.data())
                if os.path.isdir(main.current_path):
                    main.file_list=item.getItemList(main.current_path)
                    self.showDirectoryContent(main.file_list)
                    self.history.append(main.current_path)
                else:
                    if sys.platform == 'darwin':
                        c_p = main.current_path.split(' ')
                        c_p='\\ '.join(c_p)
                        print(c_p)
                        os.system("open " + c_p)
                    if sys.platform == 'win32' or sys.platform=='cygwin':
                        os.system("start "+ main.current_path)
                    if sys.platform == 'linux2':
                        os.system(".\\ '"+main.current_path+"'")
                    main.current_path = self.history[-1]
                self.refreshDirectory(main.current_path)
        except PermissionError:
            self.showError("Permission denied!")
            main.current_path = c_path
            main.file_list = item.getItemList(main.current_path)

        except :
            raise
            self.showError()
            main.current_path = c_path
            main.file_list = item.getItemList(main.current_path)
Example #2
0
 def onClickGoTo(self):#for go to button
     if os.path.exists(self.directoryTextView.toPlainText()):
         try:
             mytext = self.directoryTextView.toPlainText()
             main.current_path = mytext
             if os.path.isdir(mytext):
                 main.file_list=item.getItemList(mytext)
                 self.showDirectoryContent(main.file_list)
                 if main.current_path.split('/')[-1] == "..":
                     main.current_path = '/'.joint(main.current_path.split('/')[:-2])
                     if main.current_path == '':
                         main.current_path = '/'
                     self.directoryTextView.setText(main.current_path)
                 self.history.append(main.current_path)
             else:
                 if sys.platform == 'darwin':
                     c_p = main.current_path.split(' ')
                     c_p='\\ '.join(c_p)
                     print(c_p)
                     os.system("open " + c_p)
                 if sys.platform == 'win32' or sys.platform=='cygwin':
                     os.startfile(main.current_path)
                 if sys.platform == 'linux2':
                     os.system(".\\ '"+main.current_path+"'")
                 main.current_path = self.history[-1]
         except PermissionError:
             self.showError("Permission denied!")
         except:
             self.showError()
     else:
         self.showError(self.directoryTextView.toPlainText()+" does not exist!")
Example #3
0
 def onClickBack(self):#for back button
     if len(self.history)!= 1:
         self.history.pop()
         main.current_path = self.history[-1]
         main.file_list = item.getItemList(main.current_path)
         self.showDirectoryContent(main.file_list)
         self.directoryTextView.setText(main.current_path)
Example #4
0
    def tableClicked(self, itemm):
        c_path = self.current_path
        try:
            if itemm.column() == 0:
                if self.current_path == '/':
                    self.current_path += str(itemm.data())
                else:
                    self.current_path += '/' + str(itemm.data())
                req = "isdir:" + self.current_path
                req = req.encode("utf_8")
                self.client_socket.sendall(req)
                ans = self.client_socket.recv(self.MAX_BUFFER_SIZE)
                ans = ans.decode('utf_8')
                if ans == "T":
                    self.makeFileList()
                    self.showDirectoryContent(self.file_list)
                    self.history.append(self.current_path)
                else:
                    req = "file:" + self.current_path
                    req = req.encode("utf_8")
                    data = []
                    self.client_socket.sendall(req)
                    file = open(self.current_path.split('/')[-1], "wb")
                    while True:
                        input = self.client_socket.recv(self.MAX_BUFFER_SIZE)
                        if input != "finish,&*^".encode("utf_8"):
                            data.append(input)
                        else:
                            break
                    file.writelines(data)
                    file.close()
                    self.current_path = self.history[-1]
                self.refreshDirectory(self.current_path)
        except PermissionError:
            self.showError("Permission denied!")
            self.current_path = c_path
            self.file_list = item.getItemList(self.current_path)

        except:
            self.showError()
            self.current_path = c_path
            self.file_list = item.getItemList(self.current_path)
Example #5
0
 def pasteEvent(self):
     try:
       for i in self.selected_items:
           i.copy(main.current_path, False)
       if self.cut_selected_items and main.current_path != self.cut_selected_items[0].path:
           for i in self.cut_selected_items:
               i.copy(main.current_path, True)
               i.delete()
       main.file_list = item.getItemList(main.current_path)
       self.showDirectoryContent(main.file_list)
     except PermissionError:
         self.showError("Permission denied!")
     except :
         self.showError()
Example #6
0
 def deleteEvent(self):
     try:
         self.selected_items = []
         for i in self.itemsView.selectedItems():
             self.selected_items.append(
                 item.Item(main.current_path, i.text(), time.ctime(os.path.getmtime(main.current_path + '/' + i.text())),
                           os.path.getsize(main.getPath(main.current_path, i.text()))))
         for i in self.selected_items:
             i.delete()
         main.file_list = item.getItemList(main.current_path)
         self.showDirectoryContent(main.file_list)
     except PermissionError:
         self.showError("Permission denied!")
     except:
         self.showError()
Example #7
0
 def favoriteTableClicked(self,itemm):
     path = self.favorite_list[itemm.row()]
     if os.path.exists(path):
         try:
             mytext = path
             main.current_path = mytext
             main.file_list=item.getItemList(mytext)
             self.showDirectoryContent(main.file_list)
             self.directoryTextView.setText(main.current_path)
             self.history.append(main.current_path)
         except PermissionError:
             self.showError("Permission denied!")
         except:
             self.showError()
     else:
         self.showError(path+" does not exist!")
Example #8
0
def getItemValue(grpid):
	argv = []
	argv.append(",".join(grpid))
	argv.append("system.cpu.")
	data = item.getItemList(argv)
	hostlist = getHostList(grpid)

	ret = {}
	for host in hostlist:
		#print(host)
		ret[host["hostid"]] = {}
		ret[host["hostid"]]["ip"] = host["ip"]

	for element in data:
		ret[element["hostid"]][element["key_"]] = element["lastvalue"]
	return(ret)
Example #9
0
def getItemValue(grpid):
    argv = []
    argv.append(",".join(grpid))
    argv.append("system.cpu.")
    data = item.getItemList(argv)
    hostlist = getHostList(grpid)

    ret = {}
    for host in hostlist:
        #print(host)
        ret[host["hostid"]] = {}
        ret[host["hostid"]]["ip"] = host["ip"]

    for element in data:
        ret[element["hostid"]][element["key_"]] = element["lastvalue"]
    return (ret)
Example #10
0
 def newFolderEvent(self):
     try:
         name = "New Folder"
         text, okPressed = QInputDialog.getText(MainWindow, "Get Name", "Name:", QLineEdit.Normal, name)
         if okPressed and text != '':
             name  = text
             if os.path.exists(main.getPath(main.current_path, name)):
                 i = 1
                 while os.path.exists(main.getPath(main.current_path, name) + ' (' + str(i) + ')'):
                     i+=1
                 os.makedirs(main.getPath(main.current_path, name) + ' (' + str(i) + ')')
             else:
                 os.makedirs(main.getPath(main.current_path, name))
             main.file_list = item.getItemList(main.current_path)
             self.showDirectoryContent(main.file_list)
     except PermissionError:
         self.showError("Permission denied!")
     except:
         self.showError()
Example #11
0
import terminal_ui
import item
import os
import time

current_path = '/'
file_list = item.getItemList(current_path)


def getPath(current_path, new_directory):
    if (current_path == '/'):
        return '/' + new_directory
    else:
        return current_path + '/' + new_directory