Esempio n. 1
0
def get_file(root,path,filename):
    fh = FHandler(root)
    print(fh.current_dir())
    # if path!="/":
    #     fh.change_dir(path)
    #     print(fh.current_dir())
    content = fh.get_file_content(filename=filename,path="/")
    return content
Esempio n. 2
0
def save_file(root, path, content, filename):
    fh = FHandler(root)
    print(fh.current_dir())
    #fh.set_default_path()
    msg = fh.save_file(content=bytes(content, 'utf-8'),
                       file_name=filename,
                       path=path)
    return msg
Esempio n. 3
0
def make_dir(root,path,dir_name):
    fh = FHandler(root)
    # if path != '/':
    #     fh.change_dir(path)
    # print(fh.current_dir())
    if fh.make_dir(dir_name) == 1:
        return fh.get_hierarchy(),0
    else:
        return 0,1
Esempio n. 4
0
def pull_editor(root, project_name, branch):
    '''
    Pull the data to php folder
    send the directory structure to the user
    '''
    print(branch)
    #Set the path and make the directory
    fh = FHandler("")
    print(fh.current_dir)
    fh.make_dir(root)
    print(fh.current_dir)
    fh.change_dir(root)
    print(fh.current_dir)
    gh = GHandler()
    #perform gti fetch
    gh.git_init()
    gh.git_remote_add(project_name=project_name)
    gh.git_pull_server(branch=branch)
    #msg, flag = gh.execute()
    del gh
    del fh
    #Fetch the file structure
    fh = FHandler(root)

    hierarchy = fh.get_hierarchy()
    return hierarchy
Esempio n. 5
0
def commit(msg, branch, parent_path):
    fh = FHandler(parent_path)
    fh.set_default_path()
    gh = GHandler()
    gh.git_add()
    gh.git_commit(msg)
    gh.git_push(branch)
    res, flag = gh.execute()
    if flag:
        return "error"
    else:

        return "All good"
Esempio n. 6
0
def make_dir(root, path, new_dir):
    fh = FHandler(root)
    print(fh.current_dir())
    if path != '/':
        fh.change_dir(path)
    print(fh.current_dir())
    if fh.make_dir(new_dir) == 0:
        return "folder created"
    else:
        return "Folder already exist"
Esempio n. 7
0
def make_file(root, path, filename):
    fh = FHandler(root)
    if path != '/':
        fh.change_dir(path)
    msg = fh.make_file(fname=filename)
    print(fh.current_dir())
    return msg
            return (ps.stdout, False)

    # def check_error(self,data):
    #     if "=======" in data:
    #         return 1
    #     else:
    #         return 0

    # def find_error(self,paths):
    #     error = 0
    #     for path in paths:
    #         temp = self.cwd
    #         for d in path["path"].split("/"):
    #             temp = os.path.join(temp,d)
    #         #print(temp)
    #         f_p = os.path.join(temp,path["filename"])
    #         print(f_p)
    #         fs = open(f_p)
    #         data = fs.read()
    #         error+= self.check_error(data)
    #     return error


if __name__ == "__main__":
    fh = FHandler("test")
    base_path = fh.current_dir()
    print(base_path)
    all_files = fh.raw_file_structure()
    mh = MHandler(base_path)
    print(mh.find_error(all_files))
Esempio n. 9
0
def make_file(root,path,filename):
    fh = FHandler(root)
    if fh.make_file(fname = filename,path=path) == 1:
        return fh.get_hierarchy(),0
    else:
        return 0,1
Esempio n. 10
0
    fh = FHandler(root)
    if fh.make_file(fname = filename,path=path) == 1:
        return fh.get_hierarchy(),0
    else:
        return 0,1
def make_repo(projectname):
    # send request to the git server using API
    pass
    # ps = subprocess.Popen("ssh [email protected] git init --bare {projectname}.git".format(projectname = projectname),shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE,text=True).communicate()
    # if ps[0][0].lower() == 'i':
    #     return "created"
    # else:
    #     return "name exist"

def delete_dir(root,path,dirname){
    fh = FHandler(root)
    fh.delete_dir(dirname = dirname)
    return fh.get_hierarchy()
}

def delete_file(root,path,filename){
    fh = FHandler(root)
    fh.delete_file(filename = filename)
    return fh.get_hierarchy()
}

def tester(root):
    t = time.time()
    # fh = FHandler(dir_name= root)
    # fh.get_hierarchy()
    # fh.set_default_path()