Example #1
0
def init():
	def die(msg):
		print msg
		exit(1)

	if exists(dbFilename):
		die("The database %s already exists. If you really want to reconfigure, remove it first" % dbFilename)

	print "The database starts with a root user you can use to manage the installation"
	username = raw_input('Username: '******'':
		exit(1)
	password = getpass('Password: '******'':
		exit(1)
	print

	print "All users are assumed to share a common e-mail domain. This is currently used for gravatars and sending password reset e-mails"
	email = raw_input('E-mail domain: ')
	if email == '':
		exit(1)
	print

	print "Creating database"
	setDB(DiskMap(dbFilename, create = True))

	try:
		settings.dbVersion = LAST_SQLITE_VERSION
		settings.emailDomain = email
		settings.autolink = ([], [], [])
	except Exception, e:
		rmtree(dbFilename)
		die("Unable to set default settings: %s" % e)
Example #2
0
from rorn.Lock import getLock, setStackRecording
from stasis.Lock import setMutexProvider
setMutexProvider(lambda: getLock('#stasis'))

from Options import option, parse as parseOptions
parseOptions()
Update.check()
if option('lock-tracking'):
	setStackRecording(True)

from stasis.Singleton import set as setDB
from stasis.DiskMap import DiskMap
from LoadValues import dbFilename
def cacheLog(table):
	sys.__stdout__.write("[%s] [%s] %s\n" % (datetime.now().replace(microsecond = 0), 'stasis', "Backfilling table: %s" % table))
setDB(DiskMap(dbFilename, cache = True, nocache = ['log', 'sessions'], cacheNotifyFn = cacheLog))

from LoadValues import bricked
from Log import console
from Cron import Cron
from HTTPServer import server as getServer, ServerError
from Settings import PORT, settings
from WebSocket import WebSocket
from Event import addEventHandler
from event_handlers import *

from rorn.Session import setSerializer
from SessionSerializer import SessionSerializer
setSerializer(SessionSerializer())

currentThread().name = 'main'
Example #3
0
			print "Conversion will start in 3 seconds; depending on the database size you may see quite a lot of text go by"
			sleep(3)
			import sqlite_to_stasis
			print
			if isdir('logs'):
				rename('logs', 'logs-old')
			mkdir('logs')
			print "Database conversion complete. Ready to apply updates"

	if not isdir('db'):
		print "No database found. If you've never run this tool before, run %s --init to configure it" % sys.argv[0]
		exit(1)

	# There's no DB connection yet, so we set a temporary uncached one
	# The real cached version is set later in main
	setDB(DiskMap(dbFilename))

	if option('mode') == 'update':
		if int(settings.dbVersion) < len(updates):
			runUpdates()
			print "Updated to database version %d. %s" % (len(updates), HOW_TO_RUN)
			exit(0)
		elif int(settings.dbVersion) == len(updates):
			print "Unable to update -- already at database version %d" % len(updates)
			exit(1)
	if int(settings.dbVersion) < len(updates):
		print "The database is %s behind. Run %s --update to update it" % (pluralize(len(updates) - int(settings.dbVersion), 'version', 'versions'), sys.argv[0])
		exit(1)
	elif int(settings.dbVersion) > len(updates):
		print "The database is %s ahead; downgrading is not supported" % pluralize(int(settings.dbVersion) - DB_VERSION, 'version', 'versions')
		exit(1)