Exemplo n.º 1
0
        def execute_command(self, client, command):
            if command["command"] == "compact":
                uncompressed_count, compressed_count, purged_files_count, purged_contexts_count = self.__compact()

                client.write(
                    json_encode(
                        {
                            "status": "ok",
                            "uncompressed": uncompressed_count,
                            "compressed": compressed_count,
                            "purged_files": purged_files_count,
                            "purged_contexts": purged_contexts_count,
                        }
                    )
                )
                client.close()
            else:
                super(HighlightServer, self).execute_command(client, command)
Exemplo n.º 2
0
import os.path
import time

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")))

if "--json-job" in sys.argv[1:]:
    from syntaxhighlight.generate import generateHighlight
    from background.utils import json_decode, json_encode

    request = json_decode(sys.stdin.read())

    request["highlighted"] = generateHighlight(repository_path=request["repository_path"],
                                               sha1=request["sha1"],
                                               language=request["language"])

    sys.stdout.write(json_encode(request))
else:
    from background.utils import JSONJobServer
    from syntaxhighlight.context import importCodeContexts

    import configuration
    import dbutils

    class HighlightServer(JSONJobServer):
        def __init__(self):
            super(HighlightServer, self).__init__(service=configuration.services.HIGHLIGHT)

            self.db = dbutils.Database()

            self.register_maintenance(hour=3, minute=15, callback=self.__compact)
Exemplo n.º 3
0
import time
from subprocess import Popen as process

sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), "..")))

if "--json-job" in sys.argv[1:]:
    from syntaxhighlight.generate import generateHighlight
    from background.utils import json_decode, json_encode

    request = json_decode(sys.stdin.read())

    request["highlighted"] = generateHighlight(repository_path=request["repository_path"],
                                               sha1=request["sha1"],
                                               language=request["language"])

    sys.stdout.write(json_encode(request))
else:
    from background.utils import JSONJobServer
    from syntaxhighlight.context import importCodeContexts

    import configuration
    import dbutils

    class HighlightServer(JSONJobServer):
        def __init__(self):
            super(HighlightServer, self).__init__(service=configuration.services.HIGHLIGHT)

            self.db = dbutils.Database()

            self.register_maintenance(hour=3, minute=15, callback=self.__compact)