Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Initial commit for project.

  • Loading branch information...
commit 351b11c91266289d1223535c729b3e624664bbf9 1 parent bb1d456
@GeorgeErickson authored
View
27 fabric_config/__init__.py
@@ -0,0 +1,27 @@
+import sys, os, yaml
+
+sys.path.insert(0, os.path.dirname(__file__))
+
+DEFAULTS = {
+ 'config_name': 'fabric_config.yaml',
+}
+
+
+def setup(namespaces=['hosts']):
+ """
+ Takes all modules named in namespaces and imports them into the fabfile.
+
+ """
+ config_path = os.path.join(os.getcwd(), DEFAULTS['config_name'])
+
+ #convert config_file to dict
+ with open(config_path) as config_file:
+ config = yaml.load(config_file.read())
+
+ for namespace in namespaces:
+ ns_module = __import__(namespace)
+ ns_module.setup(config)
+
+ fab_module = sys.modules['fabfile']
+ setattr(fab_module, namespace, ns_module)
+
View
25 fabric_config/hosts.py
@@ -0,0 +1,25 @@
+import sys
+from fabric.tasks import Task
+from fabric.api import env
+class GenericHostTask(Task):
+ doc = "Sets env.host = %s"
+
+ def __init__(self, host_name, host_url):
+ self.name = "%s" % host_name
+ self.__doc__ = self.doc % host_url
+ self.host_url = host_url
+
+ def run(self):
+ env.hosts = [self.host_url]
+
+def setup(config):
+ module = sys.modules[__name__]
+
+ for host_name, host_url in config['hosts'].items():
+ generic_task = GenericHostTask(host_name, host_url)
+ setattr(module, generic_task.name, generic_task)
+
+
+
+
+
View
0  fabric_config/services/django.py
No changes.
View
2  requirements.txt
@@ -0,0 +1,2 @@
+fabric
+PyYaml
View
43 setup.py
@@ -0,0 +1,43 @@
+from setuptools import setup, find_packages
+
+#from https://github.com/cburgmer/pdfserver/blob/master/setup.py
+def parse_requirements(file_name):
+ requirements = []
+ for line in open(file_name, 'r').read().split('\n'):
+ if re.match(r'(\s*#)|(\s*$)', line):
+ continue
+ if re.match(r'\s*-e\s+', line):
+ # TODO support version numbers
+ requirements.append(re.sub(r'\s*-e\s+.*#egg=(.*)$', r'\1', line))
+ elif re.match(r'\s*-f\s+', line):
+ pass
+ else:
+ requirements.append(line)
+
+ return requirements
+
+def parse_dependency_links(file_name):
+ dependency_links = []
+ for line in open(file_name, 'r').read().split('\n'):
+ if re.match(r'\s*-[ef]\s+', line):
+ dependency_links.append(re.sub(r'\s*-[ef]\s+', '', line))
+
+ return dependency_links
+
+
+setup(
+ name = "fabric-config",
+ version = "0.1",
+ packages = find_packages(),
+
+ install_requires = parse_requirements('requirements.txt'),
+ dependency_links = parse_dependency_links('requirements.txt'),
+
+
+ # metadata for upload to PyPI
+ author = "George Erickson",
+ author_email = "george@kyruus.com",
+ description = "Helper functions for fabric, based on a config file",
+ keywords = "fabric django",
+ url = "https://github.com/GeorgeErickson/fabric-config",
+)
Please sign in to comment.
Something went wrong with that request. Please try again.