from hdfs import *
import os
import os.path
import tkinter.filedialog
import tkinter as tk
from PIL import Image,ImageTk
import tkinter.messagebox
import pickle
import numpy as np
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
from matplotlib.backend_bases import key_press_handler
from matplotlib.figure import Figure
from tkinter import ttk
import time
import sys
from pyhdfs import HdfsClient
from tkinter import filedialog
from tkinter.filedialog import askdirectory
from pathlib import Path
from hdfs3 import HDFileSystem
client=Client('http://47.112.220.22:9870')
# 调出windows文件窗口
#上传打开本地窗口
def load_window():
root = tk.Tk()
root.withdraw()
path=filedialog.askopenfilename()
return path
#下载并命名显示本地窗口
def savefile_window():
root = tk.Tk()
root.withdraw()
name=filedialog.asksaveasfilename()
return name
# 下载文件
def get_from_hdfs(path):
address=savefile_window()#调用保存文件窗口
client.download(path,address)
def main_face(username):
window = tk.Tk()
# 设置窗口大小
winWidth = 600
winHeight = 400
# 获取屏幕分辨率
screenWidth = window.winfo_screenwidth()
screenHeight = window.winfo_screenheight()
x = int((screenWidth - winWidth) / 2)
y = int((screenHeight - winHeight) / 2)
# 设置主窗口标题
window.title("功能主界面 欢迎:"+username)
# 设置窗口初始位置在屏幕居中
window.geometry("%sx%s+%s+%s" % (winWidth, winHeight, x, y))
# 设置窗口宽高固定
window.resizable(0, 0)
#移动文件
def movefile(path,username):
for item in tree.selection():
entryedit = tk.Entry(frm)
entryedit.pack()
def move():
client.rename(path[-3],path[-2]+'/'+entryedit.get()+'/')
b1 = tk.Button(frm1,text="move",width=15,height=30,command=move)
b1.pack(padx=30,pady=10,side='right')
# 删除文件
def delete_file(path,username):
if path!=rootPath1: #操作非根目录
try:
client.delete(path)
window.destroy()
root = tkinter.Tk()
root.withdraw()
tk.messagebox.showinfo(title='提示', message='操作成功!')
main_face(username)
except:
tk.messagebox.showinfo(title='提示', message='文件夹不为空!')
else:#提示根目录不能删除
root = tkinter.Tk()
root.withdraw()
tk.messagebox.showinfo(title='提示', message='此目录不能删除!')
main_face(username)
# 创建文件
def new_dir(path,username):
if(client.status(path)['type'] == 'DIRECTORY'):#如果是文件夹就执行
root=tk.Tk()
root.title('创建文件夹')
dir_name=tk.StringVar(root,value='')
tk.Label(root,text='名称:').place(x=10,y=10)
tk.Entry(root,textvariable=dir_name).place(x=30,y=10)
def get_dir_name():
dir_names = dir_name.get()
client.makedirs(path+'/'+dir_name.get(),permission=777)
root.destroy()
window.destroy()
root1 = tkinter.Tk()
root1.withdraw()
tk.messagebox.showinfo(title='提示', message='操作成功!')
main_face(username)
tk.Button(root,text='确定',command=get_dir_name).place(x=150,y=10)
else:#否则不执行
window.destroy()
root2 = tkinter.Tk()
root2.withdraw()
tk.messagebox.showinfo(title='提示', message='操作失败!')
main_face(username)
# 上传文件
def put_to_hdfs(path,username):
address=load_window()
if address=='':#点击取消之后执行
window.destroy()
root = tkinter.Tk()
root.withdraw()
tk.messagebox.showinfo(title='提示', message='请选择文件!')
main_face(username)
else:#点击文件之后执行
filename=os.path.basename(address)
if filename in client.list(path[-2]):
window.destroy()
root = tkinter.Tk()
root.withdraw()
tk.messagebox.showinfo(title='提示', message='文件已存在!')
main_face(username)
else:
if(client.status(path[-1])['type'] == 'DIRECTORY'): #上传到文件夹中
client.upload(path[-1],address)
window.destroy()
root = tkinter.Tk()
root.withdraw()
tk.messagebox.showinfo(title='提示', message='操作成功!')
main_face(username)
else:#上传到根目录
client.upload(path[-2],address)
window.destroy()
root = tkinter.Tk()
root.withdraw()
tk.messagebox.showinfo(title='提示', message='操作成功!')
main_face(username)
frm = tk.Frame(window,height = 100,width = 200)
frm1 = tk.Frame(window,height = 100,width = 200)
frm.pack(side='top')
frm1.pack()
col = [1,2,3]
tree = ttk.Treeview(frm,columns = col, show = "tree headings")
tree.heading('0',text='名称')
tree.heading('1',text='修改日期')
tree.heading('2',text='类型')
tree.heading('3',text='大小')
tree.column('0',width=150,anchor='center') #指定第一列的宽度和名称, 如果show = "headings", 这一列就被隐藏。
tree.column('1',width=150,anchor='center')
tree.column('2',width=100,anchor='center')
tree.column('3',width=100,anchor='center')
#这是传入的根目录
rootPath = '/user/hadoop/cloudpan/'+username+'/'
rootPath1 = '/user/hadoop/cloudpan/'+username+'/'+'我的文档'
def demo(tree1,rootPath):
for i in client.list(rootPath):
demoPathpath = rootPath+'/'+i
edit_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(client.status(demoPathpath)['modificationTime']/1000.0))
types = client.status(demoPathpath)['type']
length = "%.2f"%(client.status(demoPathpath)['length']/1024)+'KB'
tree2 = tree.insert(tree1,'end',text=i,values=(edit_time,types,length,i,rootPath,demoPathpath))
if(client.status(demoPathpath)['type'] == 'DIRECTORY'):
demo(tree2,demoPathpath)
def view(rootPath):
for i in client.list(rootPath):
demoPath = rootPath+i
edit_time = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(client.status(demoPath)['modificationTime']/1000.0))
types = client.status(demoPath)['type']
length = "%.2f"%(client.status(demoPath)['length']/1024)+'KB'
tree1 = tree.insert('','end',text=i,values=(edit_time,types,length,i,rootPath,demoPath))
if(client.status(demoPath)['type'] == 'DIRECTORY'):
demo(tree1,demoPath)
# 鼠标双击事件重命名
def newname(oldname,username):
for item in tree.selection():
entryedit = tk.Entry(frm)
entryedit.pack()
def save():
rename = entryedit.get()
if rename=='':#名字为空执行
window.destroy()
root = tkinter.Tk()
root.withdraw()
tk.messagebox.showinfo(title='提示', message='名称为空!')
main_fac
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
云盘系统通过互联网为企业和个人提供信息的存储、读取、下载等服务。具有安全稳定、海量等特点。目前,云盘系统逐步走向成熟,特别是公有云盘能够向用户提供免费存储,,离线下载,文件智能分类等功能。随着互联网的不断普及,用户存储在云盘上的数据量越来越大,数据类型页越来越多样化,不仅有传统的文本文件,二进制文件,还有视频,音频,图像,图片等。这些数据不仅类型繁多,而且数据量普遍庞大。例如,一个视频文件可能高达几个G甚至几十个G。因此充分利用大数据平台的优势,可以为云盘提供一套适合上述特点的底层环境。 本题目要求开发一个基于HDFS的云盘系统来实现云盘的基本数据存储和访问功能。
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
共 2 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
![avatar](https://profile-avatar.csdnimg.cn/c26801d9e761405091d5a4d37b8c884a_weixin_44606638.jpg!1)
被逼的阿陈
- 粉丝: 161
- 资源: 32
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)