Пример #1
0
def mount_local():
    """
    本地挂载
    :return:None
    """
    os.popen("/bin/mkdir /mnt/music/sda1 ; " +
             "/bin/mkdir /mnt/music/sda2 ; " +
             "/bin/mkdir /mnt/music/sdb1 ; " +
             "/bin/mkdir /mnt/music/sdb2 ; " +
             "/bin/mkdir /mnt/music/sdc1 ; " +
             "/bin/mkdir /mnt/music/sdc2 ; " +
             "/bin/mkdir /mnt/music/sdd1 ; " + "/bin/mkdir /mnt/music/sdd2")
    f = open(FILE_PATH, 'r+')
    f.truncate()
    f.write(
        PREFIX_TEXT +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sda1 /mnt/music/sda1\n" +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sda2 /mnt/music/sda2\n" +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sdb1 /mnt/music/sdb1\n" +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sdb2 /mnt/music/sdb2\n" +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sdc1 /mnt/music/sdc1\n" +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sdc2 /mnt/music/sdc2\n" +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sdd1 /mnt/music/sdd1\n" +
        "/bin/mount -o iocharset=utf8 -t auto /dev/sdd2 /mnt/music/sdd2\n" +
        "sleep 30\n\n" + SUFFIX_TEXT)
    f.close()
    sr.reboot()
Пример #2
0
def reboot():
    """
    重启
    """
    result = copy.copy(success_json)
    try:
        sb.reboot()
    except Exception, exp:
        result = copy.copy(fail_json)
        result["error"] = exp.message
Пример #3
0
def do_update(version):
    """
    执行更新
    :param version:
    :return:
    """
    download_file(version)
    time.sleep(1)
    unzip_file()
    time.sleep(1)
    sr.reboot()
Пример #4
0
def mount_network(username, password, path):
    """
    挂载
    :param username: 源系统用户名
    :param password: 源系统密码
    :param path: 源系统路径
    :return: None
    """
    os.popen("mkdir /mnt/music/network")
    f = open("/etc/fstab", 'r+')
    data = f.read()
    f.seek(0, 0)
    f.truncate()
    prefix = data.split("# NETWORK")[0]
    suffix = data.split("# TMPFS")[1]
    start = prefix + "# NETWORK\n" + "#----------------------------------------------------------------\n"
    new = start + "//" + path.strip(
    ) + " /mnt/music/network cifs username="******",password="******",iocharset=utf8,uid=dietpi,gid=dietpi,file_mode=0770,dir_mode=0770,vers=3.1.1,_netdev,nofail 0 0\n\n"
    result = new + "#----------------------------------------------------------------\n" + "# TMPFS" + suffix
    f.write(result)
    f.close()
    sr.reboot()
Пример #5
0
def umount():
    """
    卸载
    :param:
    :return:
    """
    f1 = open(FILE_PATH, 'r+')
    f1.truncate()
    f1.write(PREFIX_TEXT + SUFFIX_TEXT)
    f1.close()

    f2 = open("/etc/fstab", 'r+')
    data = f2.read()
    f2.seek(0, 0)
    f2.truncate()
    prefix = data.split("# NETWORK")[0]
    suffix = data.split("# TMPFS")[1]
    start = prefix + "# NETWORK\n" + "#----------------------------------------------------------------\n"
    new = start + "\n\n"
    result = new + "#----------------------------------------------------------------\n" + "# TMPFS" + suffix
    f2.write(result)
    f2.close()

    sr.reboot()