Skip to content

Commit

Permalink
Fix according to pycodestyle format (#4011)
Browse files Browse the repository at this point in the history
* Fix W292 no newline at end of file

* Fix extra whitespace

* Fix E305 expected 2 blank lines after class or function definition

* Fix W391 blank line at end of file

* Fix E231 missing whitespace after

* Fix E303 too many blank lines

* Fix E302 expected 2 blank lines

* Fix E128 continuation line under-indented for visual indent
  • Loading branch information
yoshiken authored and arikfr committed Aug 11, 2019
1 parent 4e5f55a commit a7b14bf
Show file tree
Hide file tree
Showing 37 changed files with 62 additions and 43 deletions.
2 changes: 1 addition & 1 deletion redash/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,4 @@ def setup_logging():
limiter = Limiter(key_func=get_ipaddr, storage_uri=settings.LIMITER_STORAGE)

import_query_runners(settings.QUERY_RUNNERS)
import_destinations(settings.DESTINATIONS)
import_destinations(settings.DESTINATIONS)
2 changes: 0 additions & 2 deletions redash/authentication/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,3 @@ def send_password_reset_email(user):

send_mail.delay([user.email], subject, html_content, text_content)
return reset_link


1 change: 1 addition & 0 deletions redash/authentication/org_resolving.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ def _get_current_org():
logging.debug("Current organization: %s (slug: %s)", g.org, slug)
return g.org


# TODO: move to authentication
current_org = LocalProxy(_get_current_org)
1 change: 1 addition & 0 deletions redash/authentication/remote_user_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

blueprint = Blueprint('remote_user_auth', __name__)


@blueprint.route(org_scoped_rule("/remote_user/login"))
def login(org_slug=None):
unsafe_next_path = request.args.get('next')
Expand Down
2 changes: 1 addition & 1 deletion redash/cli/data_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def list(organization=None):

def validate_data_source_type(type):
if type not in query_runners.keys():
print ("Error: the type \"{}\" is not supported (supported types: {})."
print("Error: the type \"{}\" is not supported (supported types: {})."
.format(type, ", ".join(query_runners.keys())))
print("OJNK")
exit(1)
Expand Down
1 change: 1 addition & 0 deletions redash/destinations/chatwork.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,5 @@ def notify(self, alert, query, user, new_state, app, host, options):
except Exception:
logging.exception('ChatWork send ERROR.')


register(ChatWork)
3 changes: 2 additions & 1 deletion redash/destinations/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def notify(self, alert, query, user, new_state, app, host, options):
else:
text = alert.name + " went back to normal"
color = "#27ae60"

payload = {'attachments': [{'text': text, 'color': color, 'fields': fields}]}

if options.get('username'): payload['username'] = options.get('username')
Expand All @@ -83,4 +83,5 @@ def notify(self, alert, query, user, new_state, app, host, options):
except Exception:
logging.exception("Slack send ERROR.")


register(Slack)
2 changes: 1 addition & 1 deletion redash/handlers/authentication.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ def verify(token, org_slug=None):
models.db.session.add(user)
models.db.session.commit()

template_context = { "org_slug": org_slug } if settings.MULTI_ORG else {}
template_context = {"org_slug": org_slug} if settings.MULTI_ORG else {}
next_url = url_for('redash.index', **template_context)

return render_template("verify.html", next_url=next_url)
Expand Down
4 changes: 2 additions & 2 deletions redash/handlers/chrome_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def chrome_log(response):
request.method, request.path, response.status_code, request_duration, queries_count, queries_duration)

chromelogger.group_collapsed(group_name)

endpoint = (request.endpoint or 'unknown').replace('.', '_')
chromelogger.info('Endpoint: {}'.format(endpoint))
chromelogger.info('Content Type: {}'.format(response.content_type))
Expand All @@ -49,6 +49,6 @@ def chrome_log(response):

def init_app(app):
if not app.debug:
return
return

app.after_request(chrome_log)
2 changes: 1 addition & 1 deletion redash/handlers/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def event_details(event):
if event.object_type == 'data_source' and event.action == 'execute_query':
details['query'] = event.additional_properties['query']
details['data_source'] = event.object_id
elif event.object_type == 'page' and event.action =='view':
elif event.object_type == 'page' and event.action == 'view':
details['page'] = event.object_id
else:
details['object_id'] = event.object_id
Expand Down
2 changes: 1 addition & 1 deletion redash/handlers/organization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def organization_status(org_slug=None):
'alerts': models.Alert.all(group_ids=current_user.group_ids).count(),
'data_sources': models.DataSource.all(current_org, group_ids=current_user.group_ids).count(),
'queries': models.Query.all_queries(current_user.group_ids, current_user.id, include_drafts=True).count(),
'dashboards': models.Dashboard.query.filter(models.Dashboard.org==current_org, models.Dashboard.is_archived==False).count(),
'dashboards': models.Dashboard.query.filter(models.Dashboard.org == current_org, models.Dashboard.is_archived == False).count(),
}

return json_response(dict(object_counters=counters))
1 change: 1 addition & 0 deletions redash/metrics/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def calculate_metrics(response):

return response


MockResponse = namedtuple('MockResponse', ['status_code', 'content_type', 'content_length'])


Expand Down
2 changes: 1 addition & 1 deletion redash/query_runner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ def guess_type_from_string(string_value):
except (ValueError, OverflowError):
pass

return TYPE_STRING
return TYPE_STRING
1 change: 1 addition & 0 deletions redash/query_runner/axibase_tsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,4 +195,5 @@ def get_schema(self, get_stats=False):
values = schema.values()
return values


register(AxibaseTSD)
1 change: 1 addition & 0 deletions redash/query_runner/clickhouse.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,4 +150,5 @@ def run_query(self, query, user):
error = unicode(e)
return data, error


register(ClickHouse)
22 changes: 11 additions & 11 deletions redash/query_runner/drill.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,17 @@ def run_query(self, query, user):
def get_schema(self, get_stats=False):

query = """
SELECT DISTINCT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME
FROM
INFORMATION_SCHEMA.`COLUMNS`
WHERE
TABLE_SCHEMA not in ('INFORMATION_SCHEMA', 'information_schema', 'sys')
and TABLE_SCHEMA not like '%.information_schema'
and TABLE_SCHEMA not like '%.INFORMATION_SCHEMA'
SELECT DISTINCT
TABLE_SCHEMA,
TABLE_NAME,
COLUMN_NAME
FROM
INFORMATION_SCHEMA.`COLUMNS`
WHERE
TABLE_SCHEMA not in ('INFORMATION_SCHEMA', 'information_schema', 'sys')
and TABLE_SCHEMA not like '%.information_schema'
and TABLE_SCHEMA not like '%.INFORMATION_SCHEMA'
"""
allowed_schemas = self.configuration.get('allowed_schemas')
if allowed_schemas:
Expand Down
2 changes: 1 addition & 1 deletion redash/query_runner/google_spreadsheets.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def __init__(self, configuration):
@classmethod
def annotate_query(cls):
return False

@classmethod
def name(cls):
return "Google Sheets"
Expand Down
1 change: 1 addition & 0 deletions redash/query_runner/graphite.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,5 @@ def run_query(self, query, user):

return data, error


register(Graphite)
7 changes: 3 additions & 4 deletions redash/query_runner/hive_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,13 @@ def _get_connection(self):
database=self.configuration.get('database', 'default'),
username=self.configuration.get('username', None),
)

return connection

return connection

def run_query(self, query, user):
connection = None
try:
connection = self._get_connection()
connection = self._get_connection()
cursor = connection.cursor()

cursor.execute(query)
Expand Down Expand Up @@ -214,7 +213,7 @@ def _get_connection(self):

# create connection
connection = hive.connect(thrift_transport=transport)

return connection


Expand Down
1 change: 1 addition & 0 deletions redash/query_runner/impala_ds.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@ def run_query(self, query, user):

return json_data, error


register(Impala)
8 changes: 5 additions & 3 deletions redash/query_runner/jql.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def to_json(self):
def merge(self, set):
self.rows = self.rows + set.rows


def parse_issue(issue, field_mapping):
result = OrderedDict()
result['key'] = issue['key']
Expand Down Expand Up @@ -117,20 +118,20 @@ def __init__(cls, query_field_mapping):
'output_field_name': v
})

def get_output_field_name(cls,field_name):
def get_output_field_name(cls, field_name):
for item in cls.mapping:
if item['field_name'] == field_name and not item['member_name']:
return item['output_field_name']
return field_name

def get_dict_members(cls,field_name):
def get_dict_members(cls, field_name):
member_names = []
for item in cls.mapping:
if item['field_name'] == field_name and item['member_name']:
member_names.append(item['member_name'])
return member_names

def get_dict_output_field_name(cls,field_name, member_name):
def get_dict_output_field_name(cls, field_name, member_name):
for item in cls.mapping:
if item['field_name'] == field_name and item['member_name'] == member_name:
return item['output_field_name']
Expand Down Expand Up @@ -199,4 +200,5 @@ def run_query(self, query, user):
except KeyboardInterrupt:
return None, "Query cancelled by user."


register(JiraJQL)
1 change: 1 addition & 0 deletions redash/query_runner/mapd.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,5 @@ def test_connection(self):
finally:
connection.close


register(Mapd)
10 changes: 5 additions & 5 deletions redash/query_runner/mongodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ def get_schema(self, get_stats=False):

return schema.values()


def run_query(self, query, user):
db = self._get_db()

Expand Down Expand Up @@ -301,12 +300,12 @@ def run_query(self, query, user):

if "count" in query_data:
columns.append({
"name" : "count",
"friendly_name" : "count",
"type" : TYPE_INTEGER
"name": "count",
"friendly_name": "count",
"type": TYPE_INTEGER
})

rows.append({ "count" : cursor })
rows.append({"count": cursor})
else:
rows, columns = parse_results(cursor)

Expand All @@ -332,4 +331,5 @@ def run_query(self, query, user):

return json_data, error


register(MongoDB)
1 change: 1 addition & 0 deletions redash/query_runner/mssql.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,5 @@ def run_query(self, query, user):

return json_data, error


register(SqlServer)
1 change: 1 addition & 0 deletions redash/query_runner/mssql_odbc.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,5 @@ def run_query(self, query, user):

return json_data, error


register(SQLServerODBC)
3 changes: 2 additions & 1 deletion redash/query_runner/oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
cx_Oracle.TIMESTAMP: TYPE_DATETIME,
}


ENABLED = True
except ImportError:
ENABLED = False

logger = logging.getLogger(__name__)


class Oracle(BaseSQLQueryRunner):
noop_query = "SELECT 1 FROM dual"

Expand Down Expand Up @@ -165,4 +165,5 @@ def run_query(self, query, user):

return json_data, error


register(Oracle)
1 change: 1 addition & 0 deletions redash/query_runner/pg.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ class CockroachDB(PostgreSQL):
def type(cls):
return "cockroach"


register(PostgreSQL)
register(Redshift)
register(CockroachDB)
2 changes: 2 additions & 0 deletions redash/query_runner/phoenix.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
'DECIMAL': TYPE_FLOAT
}


class Phoenix(BaseQueryRunner):
noop_query = 'select 1'

Expand Down Expand Up @@ -118,4 +119,5 @@ def run_query(self, query, user):

return json_data, error


register(Phoenix)
1 change: 0 additions & 1 deletion redash/query_runner/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,6 @@ def run_query(self, query, user):
restricted_globals["TYPE_DATE"] = TYPE_DATE
restricted_globals["TYPE_FLOAT"] = TYPE_FLOAT


# TODO: Figure out the best way to have a timeout on a script
# One option is to use ETA with Celery + timeouts on workers
# And replacement of worker process every X requests handled.
Expand Down
1 change: 1 addition & 0 deletions redash/query_runner/qubole.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,5 @@ def _get_header(self):
return {"Content-type": "application/json", "Accept": "application/json",
"X-AUTH-TOKEN": self.configuration['token']}


register(Qubole)
1 change: 1 addition & 0 deletions redash/query_runner/salesforce.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,5 @@ def get_schema(self, get_stats=False):
schema[table_name] = {'name': table_name, 'columns': [f['name'] for f in fields]}
return schema.values()


register(Salesforce)
1 change: 1 addition & 0 deletions redash/query_runner/sqlite.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,5 @@ def run_query(self, query, user):
connection.close()
return json_data, error


register(Sqlite)
3 changes: 2 additions & 1 deletion redash/query_runner/treasuredata.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def configuration_schema(cls):
'default': False
}
},
'required': ['apikey','db']
'required': ['apikey', 'db']
}

@classmethod
Expand Down Expand Up @@ -116,4 +116,5 @@ def run_query(self, query, user):
error = "%s: %s" % (e.message, cursor.show_job().get('debug', {}).get('stderr', 'No stderr message in the response'))
return json_data, error


register(TreasureData)
3 changes: 2 additions & 1 deletion redash/query_runner/vertica.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def run_query(self, query, user):
'database': self.configuration.get('database', ''),
'read_timeout': self.configuration.get('read_timeout', 600)
}

if self.configuration.get('connection_timeout'):
conn_info['connection_timeout'] = self.configuration.get('connection_timeout')

Expand Down Expand Up @@ -152,4 +152,5 @@ def run_query(self, query, user):

return json_data, error


register(Vertica)
2 changes: 1 addition & 1 deletion redash/serializers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def serialize_dashboard(obj, with_widgets=False, user=None, with_favorite_state=
widgets.append(serialize_widget(w))
else:
widget = project(serialize_widget(w),
('id', 'width', 'dashboard_id', 'options', 'created_at', 'updated_at'))
('id', 'width', 'dashboard_id', 'options', 'created_at', 'updated_at'))
widget['restricted'] = True
widgets.append(widget)
else:
Expand Down
Loading

0 comments on commit a7b14bf

Please sign in to comment.