File size: 1,278 Bytes
08c964e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#coding: utf-8
#-------------------------------------------------------------------
# 宝塔Linux面板
#-------------------------------------------------------------------
# Copyright (c) 2015-2099 宝塔软件(http://bt.cn) All rights reserved.
#-------------------------------------------------------------------
# Author: cjxin <cjxin@bt.cn>
#-------------------------------------------------------------------

# 备份
#------------------------------
import os,sys,re,json,shutil,psutil,time
from panelModel.base import panelBase
import public,psutil

class main(panelBase):

    def __init__(self):
        super().__init__()

    def get_disk_usage(self,get):
        """
            @name 获取目录可用空间
        """
        path = get.path
        if not os.path.exists(path):
            return public.returnMsg(False,'指定目录不存在.')

        res = psutil.disk_usage(path)
        return res

    def get_dir_used(self,get):

        """
            @name 获取目录已用空间
        """
        path = get.path
        if not os.path.exists(path):
            return public.returnMsg(False,'指定目录不存在.')

        res = public.get_size_total([path])
        if path in res:
            return res[path]
        return False