Skip to content

Commit

Permalink
Fix: no need to encode strings anymore (getredash#4627)
Browse files Browse the repository at this point in the history
* It's 2020, we got Python 3, no need to encode strings anymore

* Remove encode calls from other places

* use alert.name directly
  • Loading branch information
arikfr authored Feb 10, 2020
1 parent 86f8f32 commit 2bd8771
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
3 changes: 1 addition & 2 deletions redash/destinations/email.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ def notify(self, alert, query, user, new_state, app, host, options):
logging.debug("Notifying: %s", recipients)

try:
alert_name = alert.name.encode("utf-8", "ignore")
state = new_state.upper()
if alert.custom_subject:
subject = alert.custom_subject
else:
subject_template = options.get(
"subject_template", settings.ALERTS_DEFAULT_MAIL_SUBJECT_TEMPLATE
)
subject = subject_template.format(alert_name=alert_name, state=state)
subject = subject_template.format(alert_name=alert.name, state=state)

message = Message(recipients=recipients, subject=subject, html=html)
mail.send(message)
Expand Down
2 changes: 1 addition & 1 deletion redash/query_runner/axibase_tsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def get_schema(self, get_stats=False):
minInsertDate=self.configuration.get("min_insert_date", None),
limit=self.configuration.get("limit", 5000),
)
metrics_list = [i.name.encode("utf-8") for i in ml]
metrics_list = [i.name for i in ml]
metrics_list.append("atsd_series")
schema = {}
default_columns = [
Expand Down
2 changes: 1 addition & 1 deletion redash/query_runner/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def _send_query(self, data, stream=False):
verify = self.configuration.get("verify", True)
r = requests.post(
url,
data=data.encode("utf-8"),
data=data,
stream=stream,
timeout=self.configuration.get("timeout", 30),
params={
Expand Down
2 changes: 1 addition & 1 deletion redash/query_runner/yandex_metrica.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def _get_tables(self, schema):
for row in counters[self.list_path]:
owner = row.get("owner_login")
counter = "{0} | {1}".format(
row.get("name", "Unknown").encode("utf-8"), row.get("id", "Unknown")
row.get("name", "Unknown"), row.get("id", "Unknown")
)
if owner not in schema:
schema[owner] = {"name": owner, "columns": []}
Expand Down

0 comments on commit 2bd8771

Please sign in to comment.