User:ErsatzCulture/RunningScriptsStandalone
Jump to navigation
Jump to search
The code currently doesn't seem to be intended to be run this way, but if you want to try invoking it, these worked for me:
Running a script standalone
From within the top level directory of your checkout:
isfdb-code-svn_March2021 $ PYTHONPATH=common python mod/marque.py
This returns an HTTP response i.e. a bunch of HTTP headers followed by some HTML.
For this moderator-only page, you'll just get some standard page content (sidebars etc) and a warning message saying you're not logged in.
TODO: document how to run stuff with environment variables to pretend to be a logged in user
Running a function in a module via the REPL
I think/hope there should be a less finicky way of manipulating the PATH:
isfdb-code-svn_March2021 $ PYTHONPATH=common:mod python Python 2.7.15 (default, May 9 2018, 11:32:33) [GCC 7.3.1 20180130 (Red Hat 7.3.1-2)] on linux2 Type "help", "copyright", "credits" or "license" for more information. Running .repl.py ... .repl.py complete in 0.0 seconds >>> import marque >>> foo = list(marque.get_most_viewed_authors(10)) >>> foo [(5L, 219621L, 'Isaac Asimov'), (25L, 207832L, 'Harlan Ellison'), (194L, 157119L, 'Ray Bradbury'), (54L, 149041L, 'Robert Silverberg'), (3L, 147605L, 'Poul Anderson'), (17L, 139652L, 'Arthur C. Clarke'), (70L, 128185L, 'Stephen King'), (29L, 127362L, 'Robert A. Heinlein'), (23L, 124381L, 'Philip K. Dick'), (155L, 109854L, 'Terry Pratchett')]
NB: the above example is some code that only exists on my dev box at time of writing.