Пример #1
0
def ls():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    path = rq['path']
    h = False
    if rq.has_key('showhidden'):
        h = rq['showhidden']
        if h == 'false': h = False
        else: h = True
    if path.startswith('trash:///'): return _lstrash(u, h)
    if path.startswith('root:///'): return _lsroot(u)
    if path.startswith('file:///C:/') and not a: return 403
    p = _get_path(path, u)
    if not os.path.exists(p) or os.path.isfile(p): return 404
    rw, _r = _get_rw(u, a, p)
    if not rw and path != 'file:///': return 403
    if path in [
            'home:///', 'desktop:///', 'public:///', 'file:///', 'share:///'
    ]:
        _r[8] = path
    R = {'prop': _r}
    r = []
    l = os.listdir(p)
    l.sort()  #key=unicode.lower
    for f in l:
        if f.startswith('.'):
            if not h: continue
        fp = '%s/%s' % (p, f)
        if not os.path.exists(fp): continue
        _r = _fileinfo(fp)
        if path == 'file:///' and not _r[7]: continue
        if _r: r.append(_r)
    R['children'] = r
    return R
Пример #2
0
def craid():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    p1 = rq['path1']
    p2 = rq['path2']
    return _craid(p1, p2)
Пример #3
0
def restart():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    n = rq['name']
    _systemctl('restart', n)
    return 200
Пример #4
0
def stop():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    n = rq['name']
    _systemctl('stop', n)
    return 200
Пример #5
0
def enable():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    n = rq['name']
    e = rq['enabled']
    return _enable(e, n)
Пример #6
0
def getbluetooth():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    from service import _service_status
    if not _service_status('bluetooth'):
        os.system('sudo systemctl restart bluetooth.service')
    if not _service_status('bluealsa'):
        os.system('sudo systemctl restart bluealsa.service')
    os.system('sudo killall bt-adapter')
    c = 'sudo bt-adapter -d > /dev/null 2>&1 &'
    r = subprocess.Popen(c, shell=True, stdout=subprocess.PIPE)
    pid = r.pid
    if not rq.has_key('pid') or (
            rq.has_key('pid') and
        (rq['pid'] == ''
         or subprocess.Popen('ps aux|grep bt-adapter |grep %s' % rq['pid'],
                             shell=True,
                             stdout=subprocess.PIPE).stdout.read() == '')):
        time.sleep(10)
    c = 'sudo bt-device -l'
    r = subprocess.Popen(c, shell=True, stdout=subprocess.PIPE)
    l = r.stdout.readlines()
    _r = []
    for i in l:
        if i.startswith('Added devices:') or i.startswith('No devices found'):
            continue
        x = i.rindex('(')
        m = i[x:].strip('()\n')
        __r = _get_bt_info(m)
        if not __r: continue
        _r.append(__r)
    return {'pid': pid, 'dev': _r}
Пример #7
0
def remove():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    n = rq['name']
    os.system('sudo zerotier-cli leave %s' % n)
    return 200
Пример #8
0
def rmraid():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    p = rq['path']
    d = rq['dev']
    return _rmraid(p, d)
Пример #9
0
def status():
    u, a = auth._auth()
    if not a: return 403
    c = 'ps aux|grep kodi_v7.bin'
    r = subprocess.Popen(c, shell=True, stdout=subprocess.PIPE).stdout.read()
    if '--lircdev' in r: return {'running': True}
    return {'running': False}
Пример #10
0
def add():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    n = rq['name']
    os.system('sudo zerotier-cli join %s' % n)
    return 200
Пример #11
0
def stop():
	u,a=auth._auth()
	if not u:return 403
	rq=web.input()
	p=rq['pid']
	r=rq['rid']
	return _stop(p,r)
Пример #12
0
def rmpart():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    p = rq['path']
    n = rq['number']
    return _rmpart(p, n)
Пример #13
0
def gettemp():
    u, a = auth._auth()
    if not u: return 403
    c = 'sudo cat /sys/class/thermal/thermal_zone0/temp'
    r = subprocess.Popen(c, shell=True, stdout=subprocess.PIPE).stdout.read()
    t = round(float(r) / 1000, 1)
    return {'temp': '%s°C\n' % t}
Пример #14
0
def unzip():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    p = rq['path']
    p = _get_path(p, u)
    return _unzip(p)
Пример #15
0
def disconnectbluetooth():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    m = rq['dev']
    os.system('echo "disconnect %s\n" |sudo bluetoothctl' % m)
    return 200
Пример #16
0
def stoprecord():
	u,a=auth._auth()
	if not u:return 403
	rq=web.input()
	d=rq['pid']
	d=int(d)
	os.kill(d,3)
	return 200
Пример #17
0
def set():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    o = rq['option']
    n = rq['name']
    _systemctl(o, n)
    return 200
Пример #18
0
def screen():
	u,a=auth._auth()
	if not u:return 403
	rq=web.input()
	d=rq['dev']
	p=8000+int(d)
	_play('http://127.0.0.1:%s/?action=stream'%p,'')
	return 200
Пример #19
0
def unpairbluetooth():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    m = rq['dev']
    os.system('sudo bt-device --set %s Trusted false' % m)
    os.system('sudo bt-device -r %s' % m)
    return 200
Пример #20
0
def getconf():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    p = rq['path']
    c = _getconf(p, u)
    c['to'] = _get_uipath(c['to'], u)
    return c
Пример #21
0
def setworkgroup():
    u, a = auth._auth()
    if not u or not a: return 403
    rq = web.input()
    n = rq['name']
    n = n.replace(' ', '')
    _set_name_value('/box/etc/workgroup.conf', {'workgroup': n})
    os.system('sudo systemctl restart smbd.service')
    return 200
Пример #22
0
def find():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    p = rq['path']
    f = rq['file']
    if f.strip() == '' or p == 'trash:///' or p == 'root:///': return ls()
    p = _get_path(p, u)
    return _find(p, f)
Пример #23
0
def pairbluetooth():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    m = rq['dev']
    os.system('sudo bt-device --set %s Trusted true' % m)
    os.system('echo "yes"|sudo bt-device -c %s' % m)
    _set_asound(m)
    return 200
Пример #24
0
def set():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    e = rq['enable']
    o = rq['option']
    service._enable(e, NAME)
    service._systemctl(o, NAME)
    return 200
Пример #25
0
def get():
    u, a = auth._auth()
    if not a: return 403
    p = {'directories': ''}
    info._get_name_value(CONF, p, equal='=')
    p['directories'] = files._get_uipath(p['directories'].strip(' {"}'), u)
    p['active'] = service._service_status(NAME)
    p['enabled'] = service._service_enabled(NAME)
    return p
Пример #26
0
def get():
    u, a = auth._auth()
    if not a: return 403
    p = {'media_dir': ''}
    info._get_name_value(CONF, p)
    p['media_dir'] = files._get_uipath(p['media_dir'], u)
    p['active'] = service._service_status(NAME)
    p['enabled'] = service._service_enabled(NAME)
    return p
Пример #27
0
def mkpart():
    u, a = auth._auth()
    if not a: return 403
    rq = web.input()
    p = rq['path']
    t = rq['type']
    s = rq['start']
    e = rq['end']
    return _mkpart(p, t, s, e)
Пример #28
0
def zip():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    f = rq['file']
    f = json.loads(f)
    _f = []
    for i in f:
        _f.append(_get_path(i, u))
    return _zip(_f)
Пример #29
0
def mkdir():
    u, a = auth._auth()
    if not u: return a
    rq = web.input()
    pt = rq['path']
    p = _get_path(pt, u)
    if not p: return 400
    os.mkdir(p)
    _set_rw(u, p)
    return 200
Пример #30
0
def top():
    u, a = auth._auth()
    if not u or not a: return 403
    c = 'sudo cat /sys/class/thermal/thermal_zone0/temp'
    r0 = subprocess.Popen(c, shell=True, stdout=subprocess.PIPE).stdout.read()
    c = 'sudo top -bn 2 -i -c'
    r1 = subprocess.Popen(c, shell=True, stdout=subprocess.PIPE).stdout.read()
    t = round(float(r0) / 1000, 1)
    r1 = r1.replace('top - ', 'uptime: ')
    return {'message': 'temperature: %s°C\n%s' % (t, r1)}