Skip to content

Commit

Permalink
lint fixes;
Browse files Browse the repository at this point in the history
  • Loading branch information
twiddli committed Jan 21, 2018
1 parent f243641 commit d9f1a89
Show file tree
Hide file tree
Showing 15 changed files with 215 additions and 166 deletions.
3 changes: 2 additions & 1 deletion gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@
from multiprocessing import Process, queues
from happypanda.common import constants

#if __name__ != '__main__':
# if __name__ != '__main__':
# from gevent import monkey # noqa: E402
# # need to patch before importing requests, see https://github.com/requests/requests/issues/3752
# monkey.patch_all(thread=False)

# This is required to be here or else multiprocessing won't work when running in a frozen state!
# I had a hell of a time debugging this :(


class RedirectProcess(Process):

def __init__(self, streamqueue, exitqueue=None, initializer=None, **kwargs):
Expand Down
3 changes: 3 additions & 0 deletions happypanda/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ def parse_options(args):
if constants.dev:
sys.displayhook == pprint.pprint


def connection_params():
"Retrieve host and port"
params = (config.host.value if config.host.value else "localhost", config.port.value)
Expand Down Expand Up @@ -370,13 +371,15 @@ def temp_cwd(p):
yield
os.chdir(o)


def error_check_socket(host=None, port=None):
if port is not None:
try:
int(port)
except ValueError:
raise


class AttributeList(UserList):
"""
l = AttributeList("one", "two")
Expand Down
1 change: 0 additions & 1 deletion happypanda/interface/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ def search_item(item_type: enums.ItemType=enums.ItemType.Gallery,

order_exp, group_exp, join_exp = helpers._sort_helper(sort_by, sort_desc, db_model)


[items.append(db_msg(x)) for x in database_cmd.GetModelItems().run(db_model, model_ids, limit=limit, offset=offset,
join=join_exp, order_by=order_exp, group_by=group_exp)]

Expand Down
7 changes: 3 additions & 4 deletions happypanda/interface/helpers.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from collections import OrderedDict

from happypanda.common import utils, exceptions, hlogger, config
from happypanda.common import utils, exceptions, hlogger
from happypanda.core import db
from happypanda.interface import enums
from happypanda.core.commands import database_cmd

log = hlogger.Logger(__name__)


def _sort_helper(sort_by, sort_desc, db_model):

ordering = None
Expand Down Expand Up @@ -43,4 +42,4 @@ def _sort_helper(sort_by, sort_desc, db_model):
if sort_desc:
order_exp = tuple(db.desc_expr(x) for x in order_exp)

return order_exp, group_exp, join_exp
return order_exp, group_exp, join_exp
4 changes: 3 additions & 1 deletion happypanda/interface/tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ def get_all_tags(limit: int=100, offset: int=None):

return message.Identity('tags', msg)


def search_tags(search_query: str="",
search_options: dict = {},
only_namespace: bool=False,
Expand Down Expand Up @@ -90,14 +91,14 @@ def search_tags(search_query: str="",

order_exp, group_exp, join_exp = helpers._sort_helper(sort_by, sort_desc, db_model)


items = database_cmd.GetModelItems().run(db_model, model_ids, limit=limit, offset=offset,
join=join_exp, order_by=order_exp, group_by=group_exp)

msg = _contruct_tags_msg(items)

return message.Identity('tags', msg)


def get_tags_count():
"""
Get count of namespacetags in the database
Expand All @@ -114,6 +115,7 @@ def get_tags_count():

return message.Identity('count', {'count': s.query(db.NamespaceTags).count()})


def get_tags(item_type: enums.ItemType = enums.ItemType.Gallery,
item_id: int = 0,
raw: bool = False):
Expand Down
2 changes: 2 additions & 0 deletions templates/src/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class ViewType:
#: Inbox
Inbox = 3


class ItemSort:

#: Gallery Random
Expand Down Expand Up @@ -83,6 +84,7 @@ class ItemSort:
#: Tag
NamespaceTagTag = 31


def log(msg):
if state.debug:
print(msg)
Expand Down

0 comments on commit d9f1a89

Please sign in to comment.