예제 #1
0
def on_shutdown():
	#print "** My shutdown func **"
	import wikklytext.store.wikStore_Q as wikStore_Q
	import boodebr.sql.sqliteQ as sqliteQ
	cherrypy.log.error("Shutting down wikStore_Q worker thread")
	wikStore_Q.shutdown() # stop wikStore_Q worker thread
	cherrypy.log.error("Shutting down sqliteQ worker thread")
	sqliteQ.shutdown()
	cherrypy.log.error("Finished shutting down thread")
예제 #2
0
    def testStoreQ(self):
        from wikklytext.store.wikStore_Q import wikStore_Q, start, shutdown
        import os

        DBNAME = 'testQ.db'

        if os.path.isfile(DBNAME):
            os.unlink(DBNAME)

        start()
        store = wikStore_Q('sqlite', DBNAME)
        self.doSearchWords(store)
        shutdown()
예제 #3
0
	def testStoreQ(self):
		from wikklytext.store.wikStore_Q import wikStore_Q, start, shutdown
		import os
		
		DBNAME = 'testQ.db'
		
		if os.path.isfile(DBNAME):
			os.unlink(DBNAME)
			
		start()
		store = wikStore_Q('sqlite', DBNAME)
		self.doSearchWords(store)	
		shutdown()
예제 #4
0
def wiki_post_conv(wiki, newkind, newpath, backups):
    import wikklytext.store.wikStore_Q as wikStore_Q
    import boodebr.sql.sqliteQ as sqliteQ

    oldname = wiki.get_filename()
    oldkind = wiki.get_kind()

    # change to new store
    wiki.set_kind(newkind)
    wiki.set_filename(newpath)

    # release any open files before trying to move old wiki
    del wiki
    wikStore_Q.shutdown()
    sqliteQ.shutdown()

    if oldkind == 'text':
        # content already moved
        pass
    elif oldkind in ('tiddlywiki', 'sqlite'):
        shutil.copy(oldname, backups)
        os.unlink(oldname)
    else:
        raise Exception("Bad kind")
예제 #5
0
파일: wik.py 프로젝트: dvorberg/wikklytext
def wiki_post_conv(wiki, newkind, newpath, backups):
	import wikklytext.store.wikStore_Q as wikStore_Q
	import boodebr.sql.sqliteQ as sqliteQ
	
	oldname = wiki.get_filename()
	oldkind = wiki.get_kind()
	
	# change to new store
	wiki.set_kind(newkind)
	wiki.set_filename(newpath)

	# release any open files before trying to move old wiki
	del wiki
	wikStore_Q.shutdown()
	sqliteQ.shutdown()
	
	if oldkind == 'text':
		# content already moved
		pass
	elif oldkind in ('tiddlywiki','sqlite'):
		shutil.copy(oldname, backups)
		os.unlink(oldname)
	else:
		raise Exception("Bad kind")
예제 #6
0
def main():
    import wikklytext.version as version
    kws = {
        'usage': 'wik [options] command',
        'description': """A WikklyText meta-wiki tool.

Primary commands:
   clean     Removed all generated files.
   init      Initialize a wiki in the current directory.
   ls        List wiki content.
   render    Render wiki to HTML
   serve     Serve wiki through standalone HTTP server
   
Advanced:
   cache       Edit the list of items that should not be cached.
   conv        Convert wiki to another format (text, SQLite, TiddlyWiki)
   makeboot    Add bootstrap module to wiki, for use with mod_python.
   skip        Edit the list of items to exclude from rendering.
   trustall    Mark all existing authors as trusted (so their content
               will render in Full mode).
   updatemeta  Update wiki meta-database. May be needed after upgrading
               to a newer version of WikklyText. Safe to run multiple times.
""",
        'formatter': Formatter(),
    }
    parser = OptionParser(**kws)
    parser.add_option("-d",
                      "--directory",
                      dest='wikipath',
                      help='Specify wiki directory',
                      default=os.getcwd())
    parser.add_option("",
                      "--no-respawn",
                      dest='norespawn',
                      action='store_true',
                      default=False,
                      help='Do not auto-restart wiki server on exit')
    parser.add_option("",
                      "--cfgpath",
                      dest="configpath",
                      help="Configuration path for 'wik gui'",
                      default=None)
    parser.add_option(
        '',
        '--oldfmt',
        dest='oldformat',
        action='store_true',
        default=False,
        help='(*Debugging*) Do not update metadata when creating a new wiki')
    parser.add_option('-v',
                      '--version',
                      dest='show_version',
                      action='store_true',
                      default=False,
                      help='Show version number and exit')

    opts, args = parser.parse_args()
    if len(args) > 1:
        print "wik version %s, Copyright (C) 2007,2008 Frank McIngvale\n" % version.VSTR
        parser.print_help()
        return

    if opts.show_version:
        print 'WikklyText version %s' % version.VSTR
        return

    import wikklytext.store.wikStore_Q as wikStore_Q
    import boodebr.sql.sqliteQ as sqliteQ

    if len(args) == 0:
        cmd = 'gui'  # default command if none given
    else:
        cmd = args[0]

    if cmd not in ['serve']:
        wikStore_Q.start()  # wikserve does this itself
        sqliteQ.start()

    try:
        wikipath = os.path.abspath(opts.wikipath)

        if cmd == 'init':
            wik_init(wikipath, opts.oldformat)
        elif cmd == 'ls':
            wik_ls(wikipath)
        elif cmd == 'render':
            if DO_PROFILING:
                import cProfile, profile, pstats
                cProfile.runctx('wik_render(wikipath)', {
                    'wik_render': wik_render,
                    'wikipath': wikipath
                }, {}, 'stats.ooo')
                st = pstats.Stats('stats.ooo')
                st.sort_stats('time')
                st.print_stats(.05)
            else:
                wik_render(wikipath)

        elif cmd == 'skip':
            wik_skip(wikipath)
        elif cmd == 'clean':
            wik_clean(wikipath)
        elif cmd == 'cache':
            wik_cache(wikipath)
        elif cmd == 'serve':
            import wikklytext.scripts.wikserve as ws
            ws.run_standalone(wikipath, opts.norespawn)
        elif cmd == 'conv':
            wik_conv(wikipath)
        elif cmd == 'makeboot':
            wik_makeboot(wikipath)
        elif cmd == 'trustall':
            wik_trustall(wikipath)
        elif cmd == 'updatemeta':
            wik_updatemeta(wikipath)
        elif cmd == 'gui':
            from wikklytext.scripts.wikgui import rungui
            rungui(opts.configpath)
        else:
            print "** Unknown command: %s" % cmd
        if cmd != 'serve':
            wikStore_Q.shutdown()
            sqliteQ.shutdown()
    except:
        # catch all errors and shutdown thread
        if cmd not in ['serve']:
            wikStore_Q.shutdown()
            sqliteQ.shutdown()

        raise
예제 #7
0
 def testApi(self):
     "API test"
     # make sure errors are raised when thread not running
     shutdown()
     self.failUnlessRaises(WikStoreQError, wikStore_Q, 'sqlite', 'aaa')
     start()
예제 #8
0
 def tearDown(self):
     # make sure thread is stopped even if an error occurs in the tests
     shutdown()
예제 #9
0
	def tearDown(self):
		from wikklytext.store.wikStore_Q import shutdown
		# make sure thread is stopped even if an error occurs in the tests
		shutdown()
예제 #10
0
파일: wik.py 프로젝트: dvorberg/wikklytext
def main():
	import wikklytext.version as version
	kws = {
		'usage': 'wik [options] command',
		'description': """A WikklyText meta-wiki tool.

Primary commands:
   clean     Removed all generated files.
   init      Initialize a wiki in the current directory.
   ls        List wiki content.
   render    Render wiki to HTML
   serve     Serve wiki through standalone HTTP server
   
Advanced:
   cache       Edit the list of items that should not be cached.
   conv        Convert wiki to another format (text, SQLite, TiddlyWiki)
   makeboot    Add bootstrap module to wiki, for use with mod_python.
   skip        Edit the list of items to exclude from rendering.
   trustall    Mark all existing authors as trusted (so their content
               will render in Full mode).
   updatemeta  Update wiki meta-database. May be needed after upgrading
               to a newer version of WikklyText. Safe to run multiple times.
""",
		'formatter': Formatter(),
		}
	parser = OptionParser(**kws)
	parser.add_option("-d", "--directory", dest='wikipath',	
				help='Specify wiki directory', default=os.getcwd())
	parser.add_option("", "--no-respawn", dest='norespawn',
				action='store_true', default=False,
				help='Do not auto-restart wiki server on exit')
	parser.add_option("", "--cfgpath", dest="configpath",
				help="Configuration path for 'wik gui'", default=None)
	parser.add_option('', '--oldfmt', dest='oldformat',
				action='store_true', default=False,
				help='(*Debugging*) Do not update metadata when creating a new wiki')
	parser.add_option('-v', '--version', dest='show_version',
				action='store_true', default=False,
				help='Show version number and exit')
	
	opts,args = parser.parse_args()
	if len(args) > 1:
		print "wik version %s, Copyright (C) 2007,2008 Frank McIngvale\n" % version.VSTR
		parser.print_help()
		return

	if opts.show_version:
		print 'WikklyText version %s' % version.VSTR
		return
		
	import wikklytext.store.wikStore_Q as wikStore_Q
	import boodebr.sql.sqliteQ as sqliteQ
	
	if len(args) == 0:
		cmd = 'gui' # default command if none given
	else:
		cmd = args[0]
	
	if cmd not in ['serve']:
		wikStore_Q.start() # wikserve does this itself
		sqliteQ.start()
		
	try:	
		wikipath = os.path.abspath(opts.wikipath)
		
		if cmd == 'init':
			wik_init(wikipath, opts.oldformat)
		elif cmd == 'ls':
			wik_ls(wikipath)
		elif cmd == 'render':
			if DO_PROFILING:
				import cProfile, profile, pstats
				cProfile.runctx('wik_render(wikipath)', 
						{'wik_render': wik_render,
						 'wikipath': wikipath},{},'stats.ooo')
				st = pstats.Stats('stats.ooo')
				st.sort_stats('time')
				st.print_stats(.05)
			else:
				wik_render(wikipath)
			
		elif cmd == 'skip':
			wik_skip(wikipath)
		elif cmd == 'clean':
			wik_clean(wikipath)
		elif cmd == 'cache':
			wik_cache(wikipath)
		elif cmd == 'serve':
			import wikklytext.scripts.wikserve as ws
			ws.run_standalone(wikipath, opts.norespawn)
		elif cmd == 'conv':
			wik_conv(wikipath)
		elif cmd == 'makeboot':
			wik_makeboot(wikipath)
		elif cmd == 'trustall':
			wik_trustall(wikipath)
		elif cmd == 'updatemeta':
			wik_updatemeta(wikipath)
		elif cmd == 'gui':
			from wikklytext.scripts.wikgui import rungui
			rungui(opts.configpath)
		else:
			print "** Unknown command: %s" % cmd
		if cmd != 'serve':
			wikStore_Q.shutdown()
			sqliteQ.shutdown()
	except:
		# catch all errors and shutdown thread
		if cmd not in ['serve']:
			wikStore_Q.shutdown()
			sqliteQ.shutdown()
			
		raise