예제 #1
0
파일: shard.py 프로젝트: nerdzeu/NERDZCrush
def init(args):
    folder = _cfg("storage_folder")
    sharding_level = _cfgi("sharding")

    for i in range(64 ** sharding_level):
        try:
            os.mkdir(os.path.join(folder, int2base(i, 64)))
        except OSError as e:
            print(e)
예제 #2
0
파일: shard.py 프로젝트: Janakas/MediaCrush
def init(args):
    folder = _cfg("storage_folder")
    sharding_level = _cfgi("sharding")

    for i in range(64 ** sharding_level):
        try:
            os.mkdir(os.path.join(folder, int2base(i, 64)))
        except OSError as e:
            print(e)
예제 #3
0
    def run(self, timeout=_cfgi("max_processing_time")):
        if not self.args:
            self.args = self.command.split()

        thread = threading.Thread(target=self._target)
        thread.start()
        thread.join(timeout)

        if thread.is_alive():
            print("Terminating process")
            self.process.terminate()
            thread.join()
            self.exited = True

        self.returncode = self.process.returncode
예제 #4
0
파일: app.py 프로젝트: SCORE42/MediaCrush
    # Copy images, preprocess some JS files 
    for folder in copy:
        for f in list(os.walk(folder))[0][2]:
            outputpath = os.path.join(app.static_folder, os.path.basename(f))
            inputpath = os.path.join(folder, f)

            if inputpath in preprocess:
                with open(inputpath) as r:
                    # Using Jinja here is overkill
                    output = r.read()
                    output = output.replace("{{ protocol }}", _cfg("protocol"))
                    output = output.replace("{{ domain }}", _cfg("domain"))

                with open(outputpath, "w") as w:
                    w.write(output)
                    w.flush()
            else:
                copyfile(inputpath, outputpath)

@app.before_first_request
def compile_first():
    prepare()

@app.before_request
def compile_if_debug():
    if app.debug:
        prepare()

if __name__ == '__main__':
    app.run(host=_cfg("debug-host"), port=_cfgi('debug-port'), debug=True)
예제 #5
0
파일: app.py 프로젝트: imgrush/Imgrush
from mediacrush.app import app
from mediacrush.config import _cfg, _cfgi
import os

app.static_folder = os.path.join(os.getcwd(), "static")

if __name__ == '__main__':
    app.run(host=_cfg("debug-host"), port=_cfgi('debug-port'), debug=True)
예제 #6
0
파일: paths.py 프로젝트: DiodeZ/MediaCrush
def shard(path):
    sharding_level = _cfgi("sharding")
    return os.path.join(path[:sharding_level], path)
예제 #7
0
파일: paths.py 프로젝트: nerdzeu/NERDZCrush
def shard(path):
    sharding_level = _cfgi("sharding")
    return os.path.join(path[:sharding_level], path)