Commits

Anonymous committed 83c2468

modify directory

Comments (0)

Files changed (8)

+include LICENSE 
+recursive-include tests *
+recursive-exclude tests *.pyc
+recursive-exclude tests *.pyc
+recursive-include docs *
+recursive-exclude docs *.pyc
+recursive-exclude docs *.pyo
+prune docs/_build
+prune docs/_themes/.git

flaskext/actions.py

-# -*- coding: utf-8 -*-
-"""
-    flaskext.actions
-    ~~~~~~~~~~~~~~~~~
-
-    Description of the module goes here...
-
-    :copyright: (c) 2010 by Young King.
-    :license: BSD, see LICENSE for more details.
-"""
-import sys,os
-from werkzeug import script
-
-def runfcgi(application, before_daemon=None):
-    def action( hostname            =   ('h', ''),
-                port                =   ('p', 3001),
-                protocol            =   'scgi',
-                method              =   'threaded',
-                children            =   20,
-                daemonize           =   False,
-                pidfile             =   '/var/run/flask.pid',
-                workdir             =   '.',
-                outlog              =   '/dev/null',
-                errlog              =   '/dev/null',
-                umask               =   022,
-        ):
-        """run application use flup
-        you can choose these arguments:
-        protocol :   scgi, fcgi or ajp
-        method   :   threaded or fork
-        children :   number of threads or processes"""
-        if protocol not in ('scgi', 'fcgi', 'ajp'):
-            sys.exit('invalid protocol: %s'%protocol)
-        flup_module = 'server.%s'%protocol
-
-        kw = {'maxSpare': children, 'minSpare': children}
-
-        if protocol == 'scgi':
-            kw['scriptName'] = '/'
-
-        if method == 'threaded':
-            kw['maxThreads'] = children
-        elif method == 'fork':
-            flup_module += '_fork'
-            kw['maxChildren'] = children
-        else:
-            sys.exit('invalid method: %s'%method)
-
-        try:
-            WSGIServer = getattr(__import__('flup.' + flup_module, '', '', flup_module), 'WSGIServer')
-        except ImportError:
-            print "You need to install flup"
-            sys.exit()
-
-        if os.name!='posix' and outlog=='/dev/null':
-            outlog = None
-        if os.name!='posix' and errlog=='/dev/null':
-            errlog = None
-
-        if daemonize:
-            from .daemonize import become_daemon
-            become_daemon(workdir, outlog, errlog, umask)
-
-        if daemonize and pidfile and os.name=='posix':
-            try:
-                fp = open(pidfile, 'w')
-                fp.write("%d\n" % os.getpid())
-                fp.close()
-            except:
-                pass
-
-        if before_daemon is not None:
-            before_daemon()
-
-        WSGIServer(application, bindAddress=(hostname, port), **kw).run()
-
-    return action
-
-def bshell(app):
-    def action():
-        """run shell use bpython
-        """
-        from bpython import embed
-        embed({"app": app})
-    return action
-
-class Manager(object):
-    def __init__(self, application):
-        self.application = application
-        self._actions = {
-                'runfcgi'    :   runfcgi(application),
-                'shell'     :   script.make_shell(lambda: {"app": application},
-                                    "Interactive Flask Shell"),
-                'runserver' :   script.make_runserver(lambda: application,
-                                    use_reloader=True, threaded=True, hostname='0.0.0.0',
-                                    port=7777, use_debugger=True),
-                'bshell'    :   bshell(application),
-        }
-
-    def add_action(self, name, action):
-        self._actions[name] = action
-
-    def run(self):
-        script.run(self._actions, '')

flaskext/actions/__init__.py

+# -*- encoding:utf-8 -*-
+from .actions import Manager

flaskext/actions/actions.py

+# -*- coding: utf-8 -*-
+"""
+    flaskext.actions
+    ~~~~~~~~~~~~~~~~~
+
+    Description of the module goes here...
+
+    :copyright: (c) 2010 by Young King.
+    :license: BSD, see LICENSE for more details.
+"""
+import sys,os
+from werkzeug import script
+
+def runfcgi(application, before_daemon=None):
+    def action( hostname            =   ('h', ''),
+                port                =   ('p', 3001),
+                protocol            =   'scgi',
+                method              =   'threaded',
+                children            =   20,
+                daemonize           =   False,
+                pidfile             =   '/var/run/flask.pid',
+                workdir             =   '.',
+                outlog              =   '/dev/null',
+                errlog              =   '/dev/null',
+                umask               =   022,
+        ):
+        """run application use flup
+        you can choose these arguments:
+        protocol :   scgi, fcgi or ajp
+        method   :   threaded or fork
+        children :   number of threads or processes"""
+        if protocol not in ('scgi', 'fcgi', 'ajp'):
+            sys.exit('invalid protocol: %s'%protocol)
+        flup_module = 'server.%s'%protocol
+
+        kw = {'maxSpare': children, 'minSpare': children}
+
+        if protocol == 'scgi':
+            kw['scriptName'] = '/'
+
+        if method == 'threaded':
+            kw['maxThreads'] = children
+        elif method == 'fork':
+            flup_module += '_fork'
+            kw['maxChildren'] = children
+        else:
+            sys.exit('invalid method: %s'%method)
+
+        try:
+            WSGIServer = getattr(__import__('flup.' + flup_module, '', '', flup_module), 'WSGIServer')
+        except ImportError:
+            print "You need to install flup"
+            sys.exit()
+
+        if os.name!='posix' and outlog=='/dev/null':
+            outlog = None
+        if os.name!='posix' and errlog=='/dev/null':
+            errlog = None
+
+        if daemonize:
+            from .daemonize import become_daemon
+            become_daemon(workdir, outlog, errlog, umask)
+
+        if daemonize and pidfile and os.name=='posix':
+            try:
+                fp = open(pidfile, 'w')
+                fp.write("%d\n" % os.getpid())
+                fp.close()
+            except:
+                pass
+
+        if before_daemon is not None:
+            before_daemon()
+
+        WSGIServer(application, bindAddress=(hostname, port), **kw).run()
+
+    return action
+
+def bshell(app):
+    def action():
+        """run shell use bpython
+        """
+        from bpython import embed
+        embed({"app": app})
+    return action
+
+class Manager(object):
+    def __init__(self, application):
+        self.application = application
+        self._actions = {
+                'runfcgi'    :   runfcgi(application),
+                'shell'     :   script.make_shell(lambda: {"app": application},
+                                    "Interactive Flask Shell"),
+                'runserver' :   script.make_runserver(lambda: application,
+                                    use_reloader=True, threaded=True, hostname='0.0.0.0',
+                                    port=7777, use_debugger=True),
+                'bshell'    :   bshell(application),
+        }
+
+    def add_action(self, name, action):
+        self._actions[name] = action
+
+    def run(self):
+        script.run(self._actions, '')

flaskext/actions/daemonize.py

+# -*- coding: utf-8 -*-
+
+import os
+import sys
+
+if os.name == 'posix':
+    def become_daemon(our_home_dir='.', out_log='/dev/null',
+                      err_log='/dev/null', umask=022):
+        "Robustly turn into a UNIX daemon, running in our_home_dir."
+        # First fork
+        try:
+            if os.fork() > 0:
+                sys.exit(0)     # kill off parent
+        except OSError, e:
+            sys.stderr.write("fork #1 failed: (%d) %s\n" % (e.errno, e.strerror))
+            sys.exit(1)
+        os.setsid()
+        os.chdir(our_home_dir)
+        os.umask(umask)
+
+        # Second fork
+        try:
+            if os.fork() > 0:
+                os._exit(0)
+        except OSError, e:
+            sys.stderr.write("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror))
+            os._exit(1)
+
+        si = open('/dev/null', 'r')
+        so = open(out_log, 'a+', 0)
+        se = open(err_log, 'a+', 0)
+        os.dup2(si.fileno(), sys.stdin.fileno())
+        os.dup2(so.fileno(), sys.stdout.fileno())
+        os.dup2(se.fileno(), sys.stderr.fileno())
+        # Set custom file descriptors so that they get proper buffering.
+        sys.stdout, sys.stderr = so, se
+else:
+    def become_daemon(our_home_dir='.', out_log=None, err_log=None, umask=022):
+        """
+        If we're not running under a POSIX system, just simulate the daemon
+        mode by doing redirections and directory changing.
+        """
+        os.chdir(our_home_dir)
+        os.umask(umask)
+        sys.stdin.close()
+        sys.stdout.close()
+        sys.stderr.close()
+        if err_log:
+            sys.stderr = open(err_log, 'a', 0)
+        else:
+            sys.stderr = NullDevice()
+        if out_log:
+            sys.stdout = open(out_log, 'a', 0)
+        else:
+            sys.stdout = NullDevice()
+
+    class NullDevice:
+        "A writeable object that writes to nowhere -- like /dev/null."
+        def write(self, s):
+            pass
+
+
+class nul:
+    write = staticmethod(lambda s: None)

flaskext/daemonize.py

-# -*- coding: utf-8 -*-
-
-import os
-import sys
-
-if os.name == 'posix':
-    def become_daemon(our_home_dir='.', out_log='/dev/null',
-                      err_log='/dev/null', umask=022):
-        "Robustly turn into a UNIX daemon, running in our_home_dir."
-        # First fork
-        try:
-            if os.fork() > 0:
-                sys.exit(0)     # kill off parent
-        except OSError, e:
-            sys.stderr.write("fork #1 failed: (%d) %s\n" % (e.errno, e.strerror))
-            sys.exit(1)
-        os.setsid()
-        os.chdir(our_home_dir)
-        os.umask(umask)
-
-        # Second fork
-        try:
-            if os.fork() > 0:
-                os._exit(0)
-        except OSError, e:
-            sys.stderr.write("fork #2 failed: (%d) %s\n" % (e.errno, e.strerror))
-            os._exit(1)
-
-        si = open('/dev/null', 'r')
-        so = open(out_log, 'a+', 0)
-        se = open(err_log, 'a+', 0)
-        os.dup2(si.fileno(), sys.stdin.fileno())
-        os.dup2(so.fileno(), sys.stdout.fileno())
-        os.dup2(se.fileno(), sys.stderr.fileno())
-        # Set custom file descriptors so that they get proper buffering.
-        sys.stdout, sys.stderr = so, se
-else:
-    def become_daemon(our_home_dir='.', out_log=None, err_log=None, umask=022):
-        """
-        If we're not running under a POSIX system, just simulate the daemon
-        mode by doing redirections and directory changing.
-        """
-        os.chdir(our_home_dir)
-        os.umask(umask)
-        sys.stdin.close()
-        sys.stdout.close()
-        sys.stderr.close()
-        if err_log:
-            sys.stderr = open(err_log, 'a', 0)
-        else:
-            sys.stderr = NullDevice()
-        if out_log:
-            sys.stdout = open(out_log, 'a', 0)
-        else:
-            sys.stdout = NullDevice()
-
-    class NullDevice:
-        "A writeable object that writes to nowhere -- like /dev/null."
-        def write(self, s):
-            pass
-
-
-class nul:
-    write = staticmethod(lambda s: None)
     author_email='yanckin@gmail.com',
     description='custom actions for flask',
     long_description=__doc__,
-    packages=['flaskext'],
+    packages=['flaskext','flaskext.actions'],
     namespace_packages=['flaskext'],
+    test_suite='nose.collector',
+    tests_require=['Nose'],
     zip_safe=False,
     platforms='any',
     install_requires=[

tests/__init__.py

Empty file added.