コード例 #1
0
 def printList(event):
     select_item = self.file_list.get(self.file_list.curselection()).strip()
     #print('select_item', select_item)
     Client = client_class.Ftp_Client()
     now_top_dir = self.file_list.get(0).strip()
     if select_item == now_top_dir:
         #如果选的是顶层目录
         select_path = os.path.join(self.sys_top_dir,select_item)
         #print('顶层选择:',select_path)
         #print('-系统顶层目录', self.sys_top_dir)
         if select_path == self.user_top_dir:#如果到达个人顶层目录
             self.home_path = self.user_top_dir
             tips_str =os.path.join(self.home_name,self.User_Info['username'])
             self.Message('提示','您已处于顶层目录:%s'%tips_str,type='info')
         else:
             self.home_path = os.path.dirname(select_path)
     else:
         select_path = os.path.join(self.sys_top_dir,now_top_dir ,select_item)
         if not Client.Chk_File(select_path):
             self.home_path = select_path
             #print('jion:', self.home_path)
         else:
             self.DownLoad_File_Path = select_path
             #print('您选择了一个文件:', select_item)
             self.download_filename_label['text'] = select_item
     #print('select_path',select_path)
     add_item(self.home_path)
     del Client
コード例 #2
0
 def Auth(self):
     '''
     登录验证
     :return:
     '''
     username = self.Username_Entry.get()
     password = self.Password_Entry.get()
     password = hashlib.sha1(password.encode("utf8")).hexdigest()
     if username =='' or password == '':
         self.Message('错误','用户名/密码不能为空!',type='error')
     else:
         Client = client_class.Ftp_Client()
         auth_res = Client.Auth(username,password)
         if auth_res['auth']:
             self.User_Info = auth_res['info']
             self.SubForm.withdraw()
             self.SubForm.destroy()
             self.master.update()
             self.master.deiconify()
             self.CreateWidgets()#验证成功才创建主窗体框架
             self.Is_Login = True
             #print('验证通过')
         else:
             self.Message('登录失败',auth_res['info'],type='error')
         del Client
コード例 #3
0
 def get_file(self):
     self.download_button['state'] = DISABLED
     self.get_blok_lable['bg'] = '#FCFCFC'
     self.get_blok_lable.place(width=1)
     self.master.update_idletasks()
     if self.DownLoad_File_Path == '':
         self.Message('错误', '您没有选择任何文件!', type='error')
     else:
         Client = client_class.Ftp_Client()
         res = Client.DownLoad_File(self.DownLoad_File_Path,self.master,self.get_blok_lable,490)
         self.Message('提示', res)
         del Client
     self.download_button['state'] = NORMAL
コード例 #4
0
 def add_item(list_path):
     Client = client_class.Ftp_Client()
     #print('add_item:',list_path)
     self.file_list.delete(0, END)
     list1 = Client.Dir_List(list_path)
     #print(type(list_path),'|',list_path)
     top_dir = list_path.replace(self.sys_top_dir+self.home_sep,'')
     self.Tips_Label['text']='当前目录:%s'%top_dir
     list1.insert(0,top_dir)
     for item in list1:
         if list1.index(item) != 0: item = ' ' * 5 + item
         self.file_list.insert(END, item)
     del Client
コード例 #5
0
 def CreateWidgets(self):
     # 创建提示栏UI框架
     self.Create_Tips_Frame()
     #创建上传文件UI框架
     self.Create_UploadFile_Frame()
     #创建下载文件UI框架
     self.Create_DownloadFile_Frame()
     #检测连接和服务器平台
     Client = client_class.Ftp_Client()
     Client.handle()
     if Client.Chk_Platform == 'nt':
          self.Tips_Label['text']='服务器[基于Windows]连接正常'
     else:
          self.Tips_Label['text'] = '服务器[基于Linux]连接正常'
     Client.client.close()
コード例 #6
0
 def Create_Dir(self):
     will_create_dir = self.file_list.get(0).strip()
     dir_name = self.new_dir_entry.get().strip()
     if dir_name == '':
         self.Message('错误','请输入文件夹名',type='error')
     else:
         msg_str = '将在%s下创建%s'%(will_create_dir,dir_name)
         msg = tkinter.messagebox.askokcancel("确认?", msg_str)
         #print(msg)
         if msg:
             Client = client_class.Ftp_Client()
             res = Client.Create_Dir(will_create_dir,dir_name)
             self.Message('提示',res)
             del Client
         else:
             self.Tips_Label['text'] = '用户取消创建'
コード例 #7
0
 def put_file(self):
     self.put_file_button['state']=DISABLED
     self.put_blok_lable['bg'] = '#FCFCFC'
     self.put_blok_lable.place(width =1)
     self.master.update_idletasks()
     if self.UpLoad_File_Path == '':
         self.Message('错误','您没有选择任何文件!',type='error')
     else:
         Client = client_class.Ftp_Client()
         save_path = self.file_list.get(0)
         ############################################
         chk_size = Client.Chk_Space(self.User_Info['username'],self.User_Info['space'],self.UpLoad_File_Path)
         if chk_size:
             res = Client.UpLoad_File(self.UpLoad_File_Path,save_path,self.master,self.put_blok_lable,490)
             self.Message('提示',res)
         else:
             self.Message('警告','您的空间配额不足!',type='warning')
         del Client
     self.put_file_button['state']=NORMAL
コード例 #8
0
 def Client():
     self.Client = client_class.Ftp_Client()
コード例 #9
0
    def Create_FileList(self,DownloadFile_Frame):
        Client = client_class.Ftp_Client()
        self.file_list = Listbox(DownloadFile_Frame, selectmode="browse",bg='#BFEFFF',fg='#8A2BE2',font=("宋体", 12, "bold"))
        #个人家目录,和路径分割符
        self.home_path,self.home_sep = Client.Get_HomePath(self.User_Info['username'])
        #print('个人家目录', self.home_path)
        #系统家目录名
        self.home_name = os.path.basename(os.path.dirname(self.home_path))
        #系统顶层目录
        self.sys_top_dir = os.path.dirname(os.path.dirname(self.home_path))
        #print('系统顶层目录',self.sys_top_dir)
        #个人顶层目录
        self.user_top_dir = self.home_path
        self.DownLoad_File_Path =''
        #print('homepath:',self.home_path)
        del Client
        #Client = client_class.Ftp_Client()

        def add_item(list_path):
            Client = client_class.Ftp_Client()
            #print('add_item:',list_path)
            self.file_list.delete(0, END)
            list1 = Client.Dir_List(list_path)
            #print(type(list_path),'|',list_path)
            top_dir = list_path.replace(self.sys_top_dir+self.home_sep,'')
            self.Tips_Label['text']='当前目录:%s'%top_dir
            list1.insert(0,top_dir)
            for item in list1:
                if list1.index(item) != 0: item = ' ' * 5 + item
                self.file_list.insert(END, item)
            del Client

        add_item(self.home_path)
        self.file_list.place(in_=DownloadFile_Frame,relx=0, rely=0,x=5,y=30, width=200, height=185)

        def printList(event):
            select_item = self.file_list.get(self.file_list.curselection()).strip()
            #print('select_item', select_item)
            Client = client_class.Ftp_Client()
            now_top_dir = self.file_list.get(0).strip()
            if select_item == now_top_dir:
                #如果选的是顶层目录
                select_path = os.path.join(self.sys_top_dir,select_item)
                #print('顶层选择:',select_path)
                #print('-系统顶层目录', self.sys_top_dir)
                if select_path == self.user_top_dir:#如果到达个人顶层目录
                    self.home_path = self.user_top_dir
                    tips_str =os.path.join(self.home_name,self.User_Info['username'])
                    self.Message('提示','您已处于顶层目录:%s'%tips_str,type='info')
                else:
                    self.home_path = os.path.dirname(select_path)
            else:
                select_path = os.path.join(self.sys_top_dir,now_top_dir ,select_item)
                if not Client.Chk_File(select_path):
                    self.home_path = select_path
                    #print('jion:', self.home_path)
                else:
                    self.DownLoad_File_Path = select_path
                    #print('您选择了一个文件:', select_item)
                    self.download_filename_label['text'] = select_item
            #print('select_path',select_path)
            add_item(self.home_path)
            del Client

        self.file_list.bind('<Double-Button-1>', printList)