Skip to content

Commit

Permalink
Convert off of ClassMethods.
Browse files Browse the repository at this point in the history
All of the classmethod methods here can actually be staticmethods, since we don't make any calls to `self` at all.
  • Loading branch information
teward committed Dec 28, 2016
1 parent 95ba1d1 commit 80ec58b
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions metasmoke.py
Expand Up @@ -16,8 +16,8 @@

# noinspection PyClassHasNoInit,PyBroadException
class Metasmoke:
@classmethod
def init_websocket(self):
@staticmethod
def init_websocket():
try:
GlobalVars.metasmoke_ws = websocket.create_connection(GlobalVars.metasmoke_ws_host, origin=GlobalVars.metasmoke_host)
GlobalVars.metasmoke_ws.send(json.dumps({"command": "subscribe", "identifier": "{\"channel\":\"SmokeDetectorChannel\",\"key\":\"" + GlobalVars.metasmoke_key + "\"}"}))
Expand Down Expand Up @@ -90,8 +90,8 @@ def init_websocket(self):
except:
print "Couldn't bind to MS websocket"

@classmethod
def send_stats_on_post(self, title, link, reasons, body, username, user_link, why, owner_rep, post_score, up_vote_count, down_vote_count):
@staticmethod
def send_stats_on_post(title, link, reasons, body, username, user_link, why, owner_rep, post_score, up_vote_count, down_vote_count):
if GlobalVars.metasmoke_host is None:
print "Metasmoke location not defined, not reporting"
return
Expand All @@ -110,8 +110,8 @@ def send_stats_on_post(self, title, link, reasons, body, username, user_link, wh
except Exception as e:
print e

@classmethod
def send_feedback_for_post(self, post_link, feedback_type, user_name, user_id, chat_host):
@staticmethod
def send_feedback_for_post(post_link, feedback_type, user_name, user_id, chat_host):
if GlobalVars.metasmoke_host is None:
print "Metasmoke location not defined; not reporting"
return
Expand All @@ -136,8 +136,8 @@ def send_feedback_for_post(self, post_link, feedback_type, user_name, user_id, c
except Exception as e:
print e

@classmethod
def send_deletion_stats_for_post(self, post_link, is_deleted):
@staticmethod
def send_deletion_stats_for_post(post_link, is_deleted):
if GlobalVars.metasmoke_host is None:
print "Metasmoke location not defined; not reporting deletion stats"
return
Expand All @@ -158,8 +158,8 @@ def send_deletion_stats_for_post(self, post_link, is_deleted):
except Exception as e:
print e

@classmethod
def send_status_ping(self):
@staticmethod
def send_status_ping():
if GlobalVars.metasmoke_host is None:
print "Metasmoke location not defined; not sending status ping"
return
Expand All @@ -178,8 +178,8 @@ def send_status_ping(self):
except Exception as e:
print e

@classmethod
def update_code_privileged_users_list(self):
@staticmethod
def update_code_privileged_users_list():
payload = {'key': GlobalVars.metasmoke_key}
headers = {'Content-type': 'application/json'}
response = requests.get(GlobalVars.metasmoke_host + "/api/users/code_privileged", data=json.dumps(payload), headers=headers).json()['items']
Expand All @@ -190,8 +190,8 @@ def update_code_privileged_users_list(self):
GlobalVars.socvr_room_id: response["stackoverflow_chat_ids"]
}

@classmethod
def determine_if_autoflagged(self, post_url):
@staticmethod
def determine_if_autoflagged(post_url):
"""
Given the URL for a post, determine whether or not it has been autoflagged.
"""
Expand All @@ -202,8 +202,8 @@ def determine_if_autoflagged(self, post_url):

return is_autoflagged

@classmethod
def stop_autoflagging(self):
@staticmethod
def stop_autoflagging():
payload = {'key': GlobalVars.metasmoke_key}
headers = {'Content-type': 'application/json'}

Expand Down

0 comments on commit 80ec58b

Please sign in to comment.