Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Some small tweaks while reading the code #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hooks/config-changed
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ targets = {os.path.join(target_prefix, 'binlog.cnf'): binlog_cnf,
}

need_restart = False
for target,content in targets.iteritems():
for target,content in targets.items():
tdir = os.path.dirname(target)
if len(content) == 0 and os.path.exists(target):
os.unlink(target)
Expand Down
13 changes: 5 additions & 8 deletions hooks/shared_db_relations.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import subprocess
import json
from collections import defaultdict
import lib.utils as utils
import lib.cluster_utils as cluster

Expand All @@ -33,8 +34,7 @@ def relation_get():

def unit_sorted(units):
"""Return a sorted list of unit names."""
return sorted(
units, lambda a, b: cmp(int(a.split('/')[-1]), int(b.split('/')[-1])))
return sorted(units, lambda name: int(name.split('/')[-1]))


def get_unit_addr(relid, unitid):
Expand Down Expand Up @@ -109,12 +109,9 @@ def shared_db_changed():
# }
# }
#
databases = {}
for k, v in settings.iteritems():
db = k.split('_')[0]
x = '_'.join(k.split('_')[1:])
if db not in databases:
databases[db] = {}
databases = defaultdict(dict)
for k, v in settings.items():
db, x = k.split('_', 1)
databases[db][x] = v

return_data = {}
Expand Down
2 changes: 1 addition & 1 deletion scripts/charm_helpers_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def sync_helpers(include, src, dest, options=None):
sync(src, dest, inc, opts)
elif isinstance(inc, dict):
# could also do nested dicts here.
for k, v in inc.iteritems():
for k, v in inc.items():
if isinstance(v, list):
for m in v:
inc, opts = extract_options(m, global_options)
Expand Down