Merge ~mthaddon/charm-mongodb/+git/mongodb-charm:lint-fixes into ~mongodb-charmers/charm-mongodb:master

Proposed by Tom Haddon
Status: Merged
Approved by: Tom Haddon
Approved revision: 7f30a2db9070487d5f76a47017b8bcddd65f87c4
Merged at revision: f478e62856504dc484dfdc005fb368bb29fbb727
Proposed branch: ~mthaddon/charm-mongodb/+git/mongodb-charm:lint-fixes
Merge into: ~mongodb-charmers/charm-mongodb:master
Diff against target: 195 lines (+25/-25)
1 file modified
hooks/hooks.py (+25/-25)
Reviewer Review Type Date Requested Status
Stuart Bishop (community) Approve
Review via email: mp+359932@code.launchpad.net

Commit message

Fix lint with exception of complexity failures

Description of the change

Fix lint with exception of complexity failures

To post a comment you must log in.
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

This merge proposal is being monitored by mergebot. Change the status to Approved to merge.

Revision history for this message
Stuart Bishop (stub) wrote :

Yup

review: Approve
Revision history for this message
🤖 Canonical IS Merge Bot (canonical-is-mergebot) wrote :

Change successfully merged at revision f478e62856504dc484dfdc005fb368bb29fbb727

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/hooks/hooks.py b/hooks/hooks.py
2index 08a7d62..c23198b 100755
3--- a/hooks/hooks.py
4+++ b/hooks/hooks.py
5@@ -279,7 +279,6 @@ def mongodb_conf(config_data=None):
6 config.append("bind_ip = 0.0.0.0")
7 config.append("")
8
9-
10 # port
11 config.append("port = %d" % config_data['port'])
12 config.append("")
13@@ -594,6 +593,7 @@ def enable_replset(replicaset_name=None):
14 finally:
15 return retVal
16
17+
18 def remove_replset_from_upstart():
19 """Removes replicaset configuration from upstart.
20 """
21@@ -602,7 +602,7 @@ def remove_replset_from_upstart():
22
23 if re.search(' --replSet', mongodb_init_config,
24 re.MULTILINE) is not None:
25- mongodb_init_config = re.sub(' --replSet .\w+', '',
26+ mongodb_init_config = re.sub(r' --replSet .\w+', '',
27 mongodb_init_config)
28 retVal = update_file(default_mongodb_init_config, mongodb_init_config)
29 except Exception, e:
30@@ -634,7 +634,7 @@ def remove_rest_from_upstart():
31 try:
32 mongodb_init_config = open(default_mongodb_init_config).read()
33 if re.search(' --rest ', mongodb_init_config,
34- re.MULTILINE) is not None:
35+ re.MULTILINE) is not None:
36 mongodb_init_config = regex_sub([(' --rest ', ' ')],
37 mongodb_init_config)
38 retVal = update_file(default_mongodb_init_config, mongodb_init_config)
39@@ -684,10 +684,10 @@ def configsvr_status(wait_for=default_wait_for, max_tries=default_max_tries):
40 config_data = config()
41 current_try = 0
42
43- while (process_check_pidfile('/var/run/mongodb/configsvr.pid') !=
44- (None, None)) and not port_check(
45- unit_get('private-address'),
46- config_data['config_server_port']) and current_try < max_tries:
47+ while (process_check_pidfile('/var/run/mongodb/configsvr.pid') != (
48+ None, None)) and not port_check(
49+ unit_get('private-address'),
50+ config_data['config_server_port']) and current_try < max_tries:
51
52 juju_log("configsvr_status: Waiting for Config Server to be ready ...")
53 time.sleep(wait_for)
54@@ -775,8 +775,8 @@ def enable_configsvr(config_data, wait_for=default_wait_for,
55 def mongos_status(wait_for=default_wait_for, max_tries=default_max_tries):
56 config_data = config()
57 current_try = 0
58- while (process_check_pidfile('/var/run/mongodb/mongos.pid') !=
59- (None, None)) and not port_check(
60+ while (process_check_pidfile('/var/run/mongodb/mongos.pid') != (
61+ None, None)) and not port_check(
62 unit_get('private-address'),
63 config_data['mongos_port']) and current_try < max_tries:
64
65@@ -784,8 +784,8 @@ def mongos_status(wait_for=default_wait_for, max_tries=default_max_tries):
66 time.sleep(wait_for)
67 current_try += 1
68 retVal = \
69- (process_check_pidfile('/var/run/mongodb/mongos.pid') !=
70- (None, None)) == port_check(
71+ (process_check_pidfile('/var/run/mongodb/mongos.pid') != (
72+ None, None)) == port_check(
73 unit_get('private-address'),
74 config_data['mongos_port']) is True
75
76@@ -876,9 +876,8 @@ def restart_mongod(wait_for=default_wait_for, max_tries=default_max_tries):
77 if not service('start', 'mongodb'):
78 return False
79
80- while (service('status', 'mongodb') and
81- not port_check(my_hostname, my_port) and
82- current_try < max_tries):
83+ while (service('status', 'mongodb') and not port_check(
84+ my_hostname, my_port) and current_try < max_tries):
85 juju_log(
86 "restart_mongod: Waiting for MongoDB to be ready ({}/{})".format(
87 current_try, max_tries))
88@@ -1008,7 +1007,7 @@ def config_changed():
89 sys.exit(1)
90
91 # current ports
92- current_mongodb_port = re.search('^#*port\s+=\s+(\w+)',
93+ current_mongodb_port = re.search(r'^#*port\s+=\s+(\w+)',
94 mongodb_config,
95 re.MULTILINE).group(1)
96
97@@ -1087,7 +1086,7 @@ def config_changed():
98 juju_log("config_changed: Exception: %s" % str(e))
99
100 if configsvr_pid is not None:
101- configsvr_port = re.search('--port (\w+)', configsvr_cmd_line).group(2)
102+ configsvr_port = re.search(r'--port (\w+)', configsvr_cmd_line).group(2)
103 disable_configsvr(configsvr_port)
104 enable_configsvr(config_data['config_server_port'])
105 else:
106@@ -1103,7 +1102,7 @@ def config_changed():
107 juju_log("config_changed: Exceptions: %s" % str(e))
108
109 if mongos_pid is not None:
110- mongos_port = re.search('--port (\w+)', mongos_cmd_line).group(1)
111+ mongos_port = re.search(r'--port (\w+)', mongos_cmd_line).group(1)
112 disable_mongos(mongos_port)
113 enable_mongos(config_data['mongos_port'])
114 else:
115@@ -1139,6 +1138,7 @@ def stop_hook():
116 juju_log("stop_hook returns: %s" % retVal)
117 return(retVal)
118
119+
120 @hooks.hook('benchmark-relation-joined')
121 @hooks.hook('benchmark-relation-changed')
122 def benchmark_relation_joined():
123@@ -1155,6 +1155,7 @@ def benchmark_relation_joined():
124 benchmarks = ['perf']
125 Benchmark(benchmarks)
126
127+
128 @hooks.hook('database-relation-joined')
129 def database_relation_joined():
130 juju_log("database_relation_joined")
131@@ -1221,7 +1222,7 @@ def rs_add(host):
132
133 for i in xrange(MONGO_CLIENT_RETRIES):
134 c = MongoClient('localhost')
135- cmd_output = subprocess.check_output(cmd_line)
136+ subprocess.check_output(cmd_line)
137 r = run_admin_command(c, 'replSetGetStatus')
138 members = r["members"]
139 ok = [m for m in members if m['name'] == host and m['state'] == MONGO_SECONDARY]
140@@ -1285,8 +1286,8 @@ def get_replicaset_status():
141 # if 'self' was not found in the output, then log a warning and print
142 # the output given by replSetGetStatus
143 r_pretty = pprint.pformat(r)
144- juju_log('get_replicaset_status() failed to get replicaset state:' +
145- r_pretty, level=WARNING)
146+ juju_log('get_replicaset_status() failed to get replicaset state: '
147+ '%s' % r_pretty, level=WARNING)
148 return 'Unknown replica set state'
149
150 except OperationFailure as e:
151@@ -1296,6 +1297,7 @@ def get_replicaset_status():
152 else:
153 return str(e)
154
155+
156 def get_mongod_version():
157 """ Connects to mongod and get the db.version() output
158 Mainly used for application_set_version in config-changed hook
159@@ -1347,7 +1349,6 @@ def replica_set_relation_changed():
160 juju_log('replica_set_relation_changed-finish')
161
162
163-
164 @hooks.hook('replica-set-relation-departed')
165 def replica_set_relation_departed():
166 juju_log('replica_set_relation_departed-start')
167@@ -1546,9 +1547,9 @@ def update_nrpe_config():
168 current_unit = local_unit()
169
170 if lsb_release()['DISTRIB_RELEASE'] > '15.04':
171- check_mongo_script='check_systemd.py mongodb'
172+ check_mongo_script = 'check_systemd.py mongodb'
173 else:
174- check_mongo_script='check_upstart_job mongodb'
175+ check_mongo_script = 'check_upstart_job mongodb'
176
177 nrpe.add_check(
178 shortname='mongodb',
179@@ -1598,7 +1599,6 @@ def update_status():
180 return workload
181
182
183-
184 def run(command, exit_on_error=True):
185 '''Run a command and return the output.'''
186 try:
187@@ -1709,7 +1709,7 @@ def volume_get_volume_id():
188 # shell helper
189 def volume_init_and_mount(volid):
190 juju_log("Initialize and mount volume")
191- command = ("scripts/volume-common.sh call " +
192+ command = ("scripts/volume-common.sh call "
193 "volume_init_and_mount %s" % volid)
194 run(command)
195 return True

Subscribers

People subscribed via source and target branches

to status/vote changes: