コード例 #1
0
def init_path(l, z, n = None):
    path = Path(l, z, n)
    path.init_pos_map()
    path.init_tree()
    for i in range(1,n+1):
        path.access(i)
    print("initialized!")
    counts = [0] * (path.n+1)
    full_buckets = np.array([[0]*(l+1)], dtype=np.dtype('u2'))
    occupancies = np.array([[0]*(l+1)], dtype=np.dtype('u2'))
    return (path, counts, full_buckets, occupancies)
コード例 #2
0
ファイル: search.py プロジェクト: nasgoncalves/fsops
    def walk(self):
        for root, dirs, files in os.walk(self.path.abspath()):

            for obj in dirs:
                dir_path = Path(root) / obj
                if dir_path.access(os.R_OK):
                    yield Object.from_path(dir_path)

            for obj in files:
                file_path = Path(root) / obj
                if file_path.access(os.R_OK):
                    yield Object.from_path(file_path)
コード例 #3
0
ファイル: controler.py プロジェクト: tulanthoar/pygit
def backlight_set():
    '''dim the backlight after a set number of minutes'''
    bl_path = Path('/sys/class/backlight/intel_backlight/brightness')
    assert bl_path.access(W_OK)
    maxb_path = Path('/sys/class/backlight/intel_backlight/max_brightness')
    maxb = maxb_path.text().strip()
    maxb = '%d' % (int(maxb) // 1.2)
    while True:
        try:
            xset('dpms', 'force', 'on')
            bl_path.write_text(maxb)
            sleep(60*18)
            bl_path.write_text('300')
            sleep(60*2)
            cnt = 0
            step = 15
            minutes = 10
            while cnt < minutes*60:
                xmessage('-timeout', str(step-1), str(minutes*60-cnt))
                xset('dpms', 'force', 'off')
                sleep(step)
                cnt += step
        finally:
            bl_path.write_text(maxb)
    xset('dpms', 'force', 'on')
コード例 #4
0
ファイル: FileMonitor.py プロジェクト: hellmonky/project
 def deleteFileWithFullPath(self, deletePath):
     # 获取当前的路径
     d = Path(deletePath)
     # 判断当前路径是否可以正常访问,如果可以就在当前路径下操作,否则报错或者创建路径
     path_state = d.access(os.F_OK)
     if path_state is True:
         print(d.abspath())
         # 获取当前路径下所有的文件个数
         num_files = len(d.files())
         print("当前共有文件:"+str(num_files)+"个")
         # 然后遍历当前所有的文件
         for file in d.files():
             print(file)
         # 然后获取当前路径下的所有文件夹
         num_dirs = len(d.dirs())
         print("当前共有文件夹:"+str(num_dirs)+"个")
         # 然后遍历当前的文件夹
         for current_dir in d.dirs():
             print(current_dir)
コード例 #5
0
 def deleteFileWithFullPath(self, deletePath):
     # 获取当前的路径
     d = Path(deletePath)
     # 判断当前路径是否可以正常访问,如果可以就在当前路径下操作,否则报错或者创建路径
     path_state = d.access(os.F_OK)
     if path_state is True:
         print(d.abspath())
         # 获取当前路径下所有的文件个数
         num_files = len(d.files())
         print("当前共有文件:" + str(num_files) + "个")
         # 然后遍历当前所有的文件
         for file in d.files():
             print(file)
         # 然后获取当前路径下的所有文件夹
         num_dirs = len(d.dirs())
         print("当前共有文件夹:" + str(num_dirs) + "个")
         # 然后遍历当前的文件夹
         for current_dir in d.dirs():
             print(current_dir)
コード例 #6
0
ファイル: controler.py プロジェクト: tulanthoar/flighttimes
from path import Path
from time import sleep
from os import W_OK
from sh import xset,xmessage

bl=Path('/sys/class/backlight/intel_backlight/brightness')
assert(bl.access(W_OK))
maxb=Path('/sys/class/backlight/intel_backlight/max_brightness').text().strip()
maxb = '%d' % (int(maxb) // 1.2)
while True:
    try:
        xset('dpms', 'force', 'on')
        bl.write_text(maxb)
        sleep(60*18)
        bl.write_text('300')
        sleep(60*2)
        cnt=0
        step=15
        minutes=10
        while cnt < minutes*60:
            xmessage('-timeout', str(step-1), str(minutes*60-cnt))
            xset('dpms', 'force', 'off')
            sleep(step)
            cnt+=step
    finally:
        bl.write_text(maxb)
xset('dpms', 'force', 'on')