コード例 #1
0
ファイル: jammit.py プロジェクト: kevbahr/datafile_django
 def read_assets(self):
     """
     Read the assets from the YAML and store it as a lookup dictionary.
     """
     filepath = os.path.join(self.assets_dir, self.ASSET_FILENAME)
     f = open(filepath, 'r')
     return yaml.load(f.read())
コード例 #2
0
ファイル: config.py プロジェクト: amitagrawal/nikcub-blog
	def load(self, file, refresh=False):
		val = memcache.get('blog.yaml')
		if val is None or refresh is True:
			file_contents = open(file, 'r')
			conf_parsed = yaml.load(file_contents)
			memcache.add('blog.yaml', conf_parsed, 60)
		else:
			conf_parsed = val;
		dict.__init__(self, conf_parsed)
コード例 #3
0
ファイル: zgrep.py プロジェクト: 1761461582/NewsBlur
def main(role="app", role2="dev", command=None, path=None):
    streams = list()
    if not path:
        path = "/srv/newsblur/logs/newsblur.log"
    if not command:
        command = "tail -f"
    hosts_path = os.path.expanduser(os.path.join('../secrets-newsblur/configs/hosts.yml'))
    hosts = yaml.load(open(hosts_path))
    
    for r in [role, role2]:
        if isinstance(hosts[r], dict):
            hosts[r] = ["%s:%s" % (hosts[r][k][-1], k) for k in hosts[r].keys()]
    
    for hostname in set(hosts[role] + hosts[role2]):
        if any(h in hostname for h in IGNORE_HOSTS): continue
        if ':' in hostname:
            hostname, address = hostname.split(':', 1)
        else:
            address = hostname
        if 'ec2' in hostname:
            s = subprocess.Popen(["ssh", "-i", os.path.expanduser("~/.ec2/sclay.pem"), 
                                  address, "%s %s" % (command, path)], stdout=subprocess.PIPE)
        else:
            s = subprocess.Popen(["ssh", address, "%s %s" % (command, path)], stdout=subprocess.PIPE)
        s.name = hostname
        streams.append(s)

    try:
        i = 0
        while True:
            i += 1
            r, _, _ = select.select(
                [stream.stdout.fileno() for stream in streams], [], [])
            for fileno in r:
                for stream in streams:
                    if stream.stdout.fileno() != fileno:
                        continue
                    data = os.read(fileno, 4096)
                    if not data:
                        streams.remove(stream)
                        break
                    combination_message = "%s" % (data)
                    sys.stdout.write(combination_message)
                    break
            if i > 1000:
                break
    except KeyboardInterrupt:
        print " --- End of Logging ---"
コード例 #4
0
ファイル: _extern.py プロジェクト: Leopardob/be
def load(project, fname, optional=False, root=None):
    if fname not in self.cache:
        path = os.path.join(root or cwd(), project, "%s.yaml" % fname)
        try:
            with open(path) as f:
                self.cache[fname] = yaml.load(f) or dict()
        except IOError:
            if optional:
                self.cache[fname] = {}
            else:
                sys.stderr.write(
                    "ERROR: %s.yaml not defined "
                    "for project \"%s\"" % (fname, project))
                sys.exit(lib.USER_ERROR)

    return self.cache[fname]
コード例 #5
0
ファイル: fabfile.py プロジェクト: brainu/NewsBlur
# = DEFAULTS =
# ============

env.NEWSBLUR_PATH = "/srv/newsblur"
env.SECRETS_PATH = "/srv/secrets-newsblur"
env.VENDOR_PATH   = "/srv/code"
env.user = '******'
env.key_filename = os.path.join(env.SECRETS_PATH, 'keys/newsblur.key')

# =========
# = Roles =
# =========

try:
    hosts_path = os.path.expanduser(os.path.join(env.SECRETS_PATH, 'configs/hosts.yml'))
    roles = yaml.load(open(hosts_path))
    for role_name, hosts in roles.items():
        if isinstance(hosts, dict):
            roles[role_name] = [host for host in hosts.keys()]
    env.roledefs = roles
except:
    print " ***> No role definitions found in %s. Using default roles." % hosts_path
    env.roledefs = {
        'app'   : ['app01.newsblur.com'],
        'db'    : ['db01.newsblur.com'],
        'task'  : ['task01.newsblur.com'],
    }

def do_roledefs(split=False):
    doapi = dop.client.Client(django_settings.DO_CLIENT_KEY, django_settings.DO_API_KEY)
    droplets = doapi.show_active_droplets()
コード例 #6
0
# ============

env.NEWSBLUR_PATH = "/srv/newsblur"
env.SECRETS_PATH = "/srv/secrets-newsblur"
env.VENDOR_PATH = "/srv/code"
env.user = '******'
env.key_filename = os.path.join(env.SECRETS_PATH, 'keys/newsblur.key')

# =========
# = Roles =
# =========

try:
    hosts_path = os.path.expanduser(
        os.path.join(env.SECRETS_PATH, 'configs/hosts.yml'))
    roles = yaml.load(open(hosts_path))
    for role_name, hosts in roles.items():
        if isinstance(hosts, dict):
            roles[role_name] = [host for host in hosts.keys()]
    env.roledefs = roles
except:
    print " ***> No role definitions found in %s. Using default roles." % hosts_path
    env.roledefs = {
        'app': ['app01.newsblur.com'],
        'db': ['db01.newsblur.com'],
        'task': ['task01.newsblur.com'],
    }


def do_roledefs(split=False):
    doapi = dop.client.Client(django_settings.DO_CLIENT_KEY,