예제 #1
0
def open(name):
	name = path.cat(name, '')
	list = dircache.opendir(name)[:]
	list.sort()
	dircache.annotate(name, list)
	w = listwin.open(name, list)
	w.name = name
	w.action = action
	return w
예제 #2
0
def open(name):
       name = path.cat(name, '')
       list = dircache.opendir(name)[:]
       list.sort()
       dircache.annotate(name, list)
       w = listwin.open(name, list)
       w.name = name
       w.action = action
       return w
예제 #3
0
파일: hehe.py 프로젝트: gxyzwangyi/xinyiju
def trans(dirname):
    lis = dircache.opendir(dirname)
    for a in lis:
        af=dirname+os.sep+a
##        print af
        if os.path.isdir(af):
##            print af
            trans(af)
        else:
    ##        print af+"encoding="+fi.name
            ft = commands.getoutput('file -i '+af)
##            print ft
            if a.find('.htm')==-1 and a.find('.xml')==-1 and ft.find('text/')!=-1 and ft.find('iso-8859')!=-1:
                print 'gbk'+ft+"   >"+af
                commands.getoutput('iconv -ficonv -f gbk -t utf-8 -c -o'+" "+af+" "+af)
예제 #4
0
def copy_local_plugins(source_dir, target_dir):
    """ copied local plugins """
    if os.path.exists(sys.argv[0]):
        local_dir = os.path.dirname(sys.argv[0])
    else:
        local_dir = '.'
    local_dir = os.path.join(local_dir, source_dir)
    if os.path.exists(local_dir):
        dir_names = dircache.opendir(local_dir)
        for name in dir_names:
            from_dir = os.path.join(local_dir, name)
            if os.path.isdir(from_dir):
                to_dir = os.path.join(target_dir, name)
                print 'Copying local files from {0} to {1}'.format(
                    from_dir, to_dir)
                shutil.copytree(from_dir, to_dir)
예제 #5
0
def copy_local_plugins(source_dir, target_dir):
    """ copied local plugins """
    if os.path.exists(sys.argv[0]):
        local_dir = os.path.dirname(sys.argv[0])
    else:
        local_dir = '.'
    local_dir = os.path.join(local_dir, source_dir)
    if os.path.exists(local_dir):
        dir_names = dircache.opendir(local_dir)
        for name in dir_names:
            from_dir = os.path.join(local_dir, name)
            if os.path.isdir(from_dir):
                to_dir = os.path.join(target_dir, name)
                print 'Copying local files from {0} to {1}'.format(
                    from_dir, to_dir
                )
                shutil.copytree(from_dir, to_dir)
예제 #6
0
import math

import logging
logging.basicConfig(level=logging.DEBUG) 
# Available levels: NOSET, DEBUG, INFO, WARN, ERROR, CRITITCAL


""" number of clicks in one inch, should be 400 """
lengthScale = 1 

""" 25.6 = the number of clicks in one degree, should be 29 """
rotationScale = 1 

import os, sys, dircache
portDirectory = 'COM11'
portsAvailable = dircache.opendir(portDirectory)

""" Set the usb port and baudrate """
usb = serial.Serial()
usb.baudrate = 19200
usb.timeout = 0

""" autoselect usb port on linux machines"""
for port in portsAvailable:
    if re.search('USB', port):
        usb.port = portDirectory + port
        break


""" These lookup dictionaries are separated for convenience and clarity of function.
communications : contains the definitions for communication protocol messages
예제 #7
0
if __name__ == "__main__":
    dir_list = [
        "blue", "chartreuse", "cyan", "dark_gray", "dark_purple", "deep_pink",
        "dodger_blue", "gold", "green_yellow", "orange", "purple", "red",
        "yellow" ]
    rename_list = []
    f_name_list = open("../instruct.txt", "r")
    name = f_name_list.readline()
    while len(name) > 3:
        rename_list.append(name[:-1])
        name = f_name_list.readline()
    for d in dir_list:
        # First rename
        new_file_list = []
        file_list = dircache.opendir(d)
        for f in file_list:
            idx = int(f[f.rfind("c") + 1 : f.rfind(".")])
            if idx < 10:
                idx = "0" + str(idx)
                os.chdir("./" + d)
                new_name = f[:f.rfind("c") + 1] + idx + ".png"
                os.rename(f, new_name)
                os.chdir("..")
                new_file_list.append(new_name)
            else:
                new_file_list.append(f)
        new_file_list.sort()
        print new_file_list
        # Second rename
        os.chdir("./" + d)
예제 #8
0
import dircache

listing = dircache.opendir('/')

for f in listing:
    print f