Ejemplo n.º 1
0
 def test_find_file_sad_bad(self):
     try:
         reusables.find_files_list(name="*.*", match_case=True)
     except ValueError:
         pass
     else:
         raise AssertionError("Cant do that")
Ejemplo n.º 2
0
 def test_find_file_sad_bad(self):
     try:
         reusables.find_files_list(name="*.*", match_case=True)
     except ValueError:
         pass
     else:
         raise AssertionError("Cant do that")
Ejemplo n.º 3
0
 def test_find_file_pathlib(self):
     if reusables.python_version >= (3, 4):
         import pathlib
         files = reusables.find_files_list(test_root,
                                           ext=".cfg",
                                           abspath=True)
         assert isinstance(files[0], pathlib.Path)
         files2 = reusables.find_files_list(test_root,
                                            ext=".cfg",
                                            abspath=True,
                                            disable_pathlib=True)
         assert not isinstance(files2[0], pathlib.Path)
Ejemplo n.º 4
0
 def test_find_files_multi_ext(self):
     resp = reusables.find_files_list(test_root,
                                      ext=[".cfg", ".nope"],
                                      disable_pathlib=True)
     assert [
         x for x in resp
         if x.endswith(os.path.join(test_root, "test_config.cfg"))
     ]
Ejemplo n.º 5
0
 def test_find_with_scandir(self):
     resp = reusables.find_files_list(test_root,
                                      ext=[".cfg", ".nope"],
                                      enable_scandir=True)
     assert [
         x for x in resp
         if x.endswith(os.path.join(test_root, "test_config.cfg"))
     ]
Ejemplo n.º 6
0
 def test_find_files_name(self):
     resp = reusables.find_files_list(test_root,
                                      name="test_config",
                                      disable_pathlib=True)
     assert [
         x for x in resp
         if x.endswith(os.path.join(test_root, "test_config.cfg"))
     ]
Ejemplo n.º 7
0
 def test_find_files(self):
     resp = reusables.find_files_list(test_root, ext=".cfg")
     assert [
         x for x in resp
         if x.endswith(os.path.join(test_root, "test_config.cfg"))
     ]
Ejemplo n.º 8
0
 def test_count_name(self):
     self._extract_structure()
     resp = reusables.count_files(test_root, name="file_")
     assert resp == 4, reusables.find_files_list(test_root,
                                                 name="file_",
                                                 abspath=True)
Ejemplo n.º 9
0
 def test_count_name(self):
     self._extract_structure()
     resp = reusables.count_files(test_root, name="file_")
     assert resp == 4, reusables.find_files_list(test_root, name="file_",
                                                 abspath=True)
Ejemplo n.º 10
0
 def test_find_with_scandir(self):
     resp = reusables.find_files_list(test_root, ext=[".cfg", ".nope"], enable_scandir=True)
     assert [x for x in resp if x.endswith(os.path.join(test_root, "test_config.cfg"))]
Ejemplo n.º 11
0
 def test_find_glob(self):
     resp = reusables.find_files_list(test_root, name="*config*")
     assert len(resp) == 3, resp
Ejemplo n.º 12
0
 def test_find_files_name(self):
     resp = reusables.find_files_list(test_root, name="test_config")
     assert [x for x in resp if x.endswith(os.path.join(test_root, "test_config.cfg"))]
Ejemplo n.º 13
0
 def test_find_files_multi_ext(self):
     resp = reusables.find_files_list(test_root, ext=[".cfg", ".nope"])
     assert [x for x in resp if x.endswith(os.path.join(test_root, "test_config.cfg"))]
Ejemplo n.º 14
0
 def test_find_files(self):
     resp = reusables.find_files_list(test_root, ext=".cfg", abspath=True)
     assert [x for x in resp if x.endswith(os.path.join(test_root, "test_config.cfg"))]
Ejemplo n.º 15
0
 def test_sync_dirs(self):
     if reusables.python_version >= (3, 4):
         pass
     files = reusables.find_files_list(test_root, ext=".cfg", abspath=True)
Ejemplo n.º 16
0
 def test_find_files_depth(self):
     self._extract_structure()
     resp = reusables.find_files_list(test_structure, depth=1)
     assert not resp, resp
     resp2 = reusables.find_files_list(test_structure, depth=2)
     assert len(resp2) == 5, resp2
Ejemplo n.º 17
0
 def test_find_glob(self):
     resp = reusables.find_files_list(test_root, name="*config*")
     assert len(resp) == 3, resp
Ejemplo n.º 18
0
 def test_find_files_depth(self):
     self._extract_structure()
     resp = reusables.find_files_list(test_structure, depth=1)
     assert not resp, resp
     resp2 = reusables.find_files_list(test_structure, depth=2)
     assert len(resp2) == 5, resp2
Ejemplo n.º 19
0
import os
from pprint import pprint

import reusables

import create_filesystem

# reusables.find_files(ext=reusables.exts)
disk_files = reusables.find_files_list('./Data',
                                       ext=('.py', '.java'),
                                       abspath=True,
                                       disable_pathlib=True)

# print(len(file_list))


def get_all_path(json, p):
    if not isinstance(json, dict):
        return

    if len(json) == 0:
        return

    if 'path' in json.keys():  # and json['path'] != ''
        p.append(json['path'])

    for v in json.values():
        get_all_path(v, p)

    if 'sub_questions' in json.keys():
        for v in json['sub_questions']:
Ejemplo n.º 20
0
@app.route('/')
def start():
    return render_template('main.html',
                           data={
                               'questions': data[topics[0]],
                               'current_topic': topics[0],
                               'topics': topics
                           })


@app.route('/shutdown', methods=['GET'])
def shutdown():
    print("got here")
    os.popen("sh /home/nishan/project/DSA/runner.sh")
    # os.system("sh /home/nishan/project/DSA/runner.sh")
    # p = Process(target=lambda: os.system("sh /home/nishan/project/DSA/runner.sh"), args=())
    # p.start()
    # p.join()


if __name__ == '__main__':
    files = reusables.find_files_list("Data")
    files += Path(os.path.abspath("data.txt")).as_posix()

    # from gevent.pywsgi import WSGIServer
    # http_server = WSGIServer(('', 5000), app)
    # http_server.serve_forever()

    app.run(use_reloader=True, port=5000, extra_files=files)
    app.run()