Beispiel #1
0
	def __init__(self):
		"""Sets files to use with the daemon and runs the mainloop by invoking the super."""

		pidfile = data_uri("service_daemon.pid")
		stdout = data_uri("logs/service_daemon_stdout.log")
		stderr = data_uri("logs/service_daemon_stderr.log")
		BaseDaemon.__init__(self, pidfile, "/dev/null", stdout, stderr)
Beispiel #2
0
def setup_directories():
    dirs = [
        data_uri("tmp"),
        data_uri("logs"),
        static_uri("images/uploads")
    ]

    for d in dirs:
        os.makedirs(d)
Beispiel #3
0
def create_logger(name):
	"""Creates a new file logger (rotating files) with the given name"""

	formatter = logging.Formatter("[%(asctime)s] [%(levelname)s]: %(message)s")
	file_handler = RotatingFileHandler(data_uri("logs/%s.log" % name), "a", 200000)
	file_handler.setFormatter(formatter)
	logger = logging.getLogger(name)
	logger.addHandler(file_handler)
	logger.setLevel(logging.DEBUG)

	return (logger, file_handler)
Beispiel #4
0
	def test_data_uri(self):
		data = [
			(
				path.root_uri + "data/logs", 
				path.data_uri("logs")
			),
			(
				path.root_uri + "data/tmp/test.png",
				path.data_uri("tmp/test.png")
			),
			(
				path.root_uri + "data/logs/service_daemon.log", 
				path.data_uri(filename = "logs/service_daemon.log")
			),
			(
				"sqlite://" + path.root_uri + "data/database.db", 
				path.data_uri("database.db", "sqlite://")
			),
		 	(
				"sqlite://" + path.root_uri + "data/database.db", 
				path.data_uri("database.db", prefix = "sqlite://")
			),
			(
				"sqlite://" + path.root_uri + "data/database.db", 
				path.data_uri(filename = "database.db", prefix = "sqlite://")
			)
		]

		for expected, result in data:
			self.assertEqual(expected, result)
Beispiel #5
0
import sys

from os import path

from general import settings

from general.utils.path import (
	data_uri,
	static_uri
)

if not path.isdir(data_uri("")):
	print "[ERROR] Data directory was not found, fatal error!"
	sys.exit(1)

if not path.exists(data_uri("datastore.db")):
	print "[ERROR] Database file was not found, fatal error!"
	sys.exit(1)

if not path.isdir(settings.IMAGESTORE_URI):
	print "[ERROR] Image uploads directory was not found, fatal error!"
	sys.exit(1)