示例#1
0
def add_dictionary(path,name):
    path = fs.expand_path(path)
    mode = path.split("/")[-1].split(".")[0]
    fs.create("~/.lir/actions/"+mode+".dic")
    with open(fs.expand_path("~/.lir/actions/"+mode+".dic"),'a') as f:
        f.write("\n####\n#  "+name+"\n####\n")
        with open(path) as src:
            f.write(src.read())
示例#2
0
def test__when_deleting_file__should_remove_file_from_fs():
    fs = MemoryFS()
    fs.create(SOURCE)

    sut = _TestFilesystemImpl(fs)

    sut.delete(SOURCE)

    assert not fs.exists(SOURCE)
示例#3
0
def main():
    fs.init('fs')
    fs.mkdir('a')
    fs.mkdir('b')
    fs.mkdir('a/c')
    fs.create('a/d.txt', 20)
    fs.create('a/c/e.txt', 20)
    fd1 = fs.open('a/d.txt', 'rw')
    fd2 = fs.open('a/c/e.txt', 'rw')
    fs.write(fd1, 'hello\nbye\n')
    fs.write(fd2, 'goodbye\n')
    print fs.read(fd2, 4)
    print fs.readlines(fd1)
    for f in fs.readlines(fd1):
        print(f),
    fs.close(fd1)
    fs.close(fd2)
    fs.suspend()
示例#4
0
def main():
    print(lang.get("setup","welcome"))
    print(lang.get("setup","info"))
    print()
    print(lang.get("setup","notice"))
    print()
    #Create directories
    fs.delete("~/.lir")
    fs.create_directory("~/.lir")
    for d in ["plugins","tts","stt","actions","services","bin","langs"]:
        fs.create_directory("~/.lir/"+d)
    fs.create("~/.lir/actions/default.dic")
    fs.copy("langs","~/.lir/langs")
        
    #Create ini
    ini = settings.ini("~/.lir/main.ini")
    ini.create_section("general")
    try:
        import pwd,os
        name = pwd.getpwuid(os.getuid())[4].replace(",","")
        print()
        if input("Is "+name+" your name? [Y/N]").lower() == "y":
            ini.set("general","name",name)
        else:
            ini.set("general","name",input(lang.get("setup","name")))
    except:
        ini.set("general","name",input(lang.get("setup","name")))
        
    #make dictionary program
    debug(lang.get("setup","build"),"Dictionary")
    os.chdir("dictionary")
    fs.delete("dictionary")
    if DEBUG:
        os.system("make")
    else:
        fs.system("make")
    os.chdir("../")
    fs.copy("dictionary/dictionary","~/.lir/dictionary")
        
    #Install required packages
    
    #Install default plugins
    dev_plugins = os.listdir("dev_plugins")
    for plugin in dev_plugins:
        if not pm.installFolder("dev_plugins/" + plugin):
            print(lang.get("error","install"), plugin)
    
    #FIXME install twice
    if not pm.installFolder("dev_plugins/espeak"):
        print(lang.get("error","install"),"espeak")
    else:
        ini.create_section("tts")
        #right now espeak is the default tts engine
        ini.set("tts","engine","espeak")
        print()
        #ask if tts should be used
        ini.set("tts","read-responses",str(input("Do you want Lir to read out responses? [Y/N]").lower() == "y"))
        print()
        
    #copy needed python scripts
    for f in ["settings.py","lang.py","fs.py","lir.py"]:
        fs.copy(f,"~/.lir/bin")
        fs.copy(f,"~/.lir/services")
        fs.copy(f,"~/.lir/tts")
        
    #Create server info in config
    ini.create_section("server")
    ini.set("server","host","127.0.0.1")
    ini.set("server","port","8090")
        
    debug("Saving ini")
    ini.save()
    print()
    print(lang.get("setup","done"))
示例#5
0
文件: store_test.py 项目: andref/ipe
def setup():
    fs.create()
示例#6
0
import fs
fs.init('myfs')

# if __name__ == '__main__':
fs.init('myfs')
fs.getcwd()  # /
fs.mkdir('a0')
fs.mkdir('a0/a1')
fs.mkdir('a0/a1/a2')
fs.listdir()
fs.listdir('a0')
fs.mkdir('a0/b1')
fs.listdir('a0')
fs.chdir('a0/b1')  # /a0/b1
fs.create('../a1/a2.txt', 10)
fs.listdir('../a1')
fs.chdir('/a0/a1')  # /a0/a1
fs.getcwd()
try:
    fs.mkdir('../a1')
except Exception, e:
    print e
try:
    fs.chdir('../c1')
except Exception, e:
    print e
fs.getcwd()
try:
    fs.deldir('/a0/a1')
except Exception, e:
    print e
示例#7
0
# file system tree #1
#now it is on the root directory.
fs.init('abc')

fs.mkdir('a')

fs.mkdir('a/b1')
print fs.listdir('a')

#now it is on the root directory.
#fs.chdir('a')

fs.chdir('/')

fs.create('fa', 17)
print fs.listdir('.')

#on a directory
fs.chdir('a')

fs.mkdir('b2')

fs.mkdir('/a/b3')

#now on drectory b3

fs.chdir('b3')

fs.mkdir('/a/b1/c1')
print fs.listdir('/a/b1')