Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Rename VisionControllerClient to VisionClient #46

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mujinvisioncontrollerclient/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2014-2015 MUJIN Inc.
from .version import __version__ # noqa: F401
from .visioncontrollerclienterror import VisionControllerClientError, VisionControllerTimeoutError # noqa: F401
from .visionclienterror import VisionClientError, VisionControllerClientError, VisionTimeoutError, VisionControllerTimeoutError # noqa: F401


try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@

import six
import unittest
from mujinvisioncontrollerclient import visioncontrollerclienterror
from . import visionclienterror


class TestMethods(unittest.TestCase):
def test_str(self):
errorType = "错误类型"
errorDesc = "错误描述"
err = visioncontrollerclienterror.VisionControllerClientError(
err = visionclienterror.VisionClientError(
errortype=errorType, errordesc=errorDesc
)
if six.PY2:
self.assertEqual(
str(err), (u"VisionControllerClientError: %s, %s" % (errorType.decode("utf-8"), errorDesc.decode("utf-8"))).encode("utf-8")
str(err), (u"VisionClientError: %s, %s" % (errorType.decode("utf-8"), errorDesc.decode("utf-8"))).encode("utf-8")
)
else:
self.assertEqual(
str(err), (u"VisionControllerClientError: %s, %s" % (errorType, errorDesc))
str(err), (u"VisionClientError: %s, %s" % (errorType, errorDesc))
)

def test_unicode(self):
errorType = u"错误类型"
errorDesc = u"错误描述"
err = visioncontrollerclienterror.VisionControllerClientError(
err = visionclienterror.VisionClientError(
errortype=errorType, errordesc=errorDesc
)
if six.PY2:
self.assertEqual(
str(err), (u"VisionControllerClientError: %s, %s" % (errorType, errorDesc)).encode("utf-8")
str(err), (u"VisionClientError: %s, %s" % (errorType, errorDesc)).encode("utf-8")
)
else:
self.assertEqual(
str(err), (u"VisionControllerClientError: %s, %s" % (errorType, errorDesc))
str(err), (u"VisionClientError: %s, %s" % (errorType, errorDesc))
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

# mujin imports
from mujinplanningclient import zmqclient, zmqsubscriber, TimeoutError
from . import VisionControllerClientError, VisionControllerTimeoutError
from . import VisionClientError, VisionTimeoutError
from . import json
from . import zmq
from . import ugettext as _
Expand All @@ -19,8 +19,8 @@
import logging
log = logging.getLogger(__name__)

class VisionControllerClient(object):
"""Mujin Vision Controller client for binpicking tasks."""
class VisionClient(object):
"""Mujin Vision client for the binpicking tasks."""

_ctx = None # type: Optional[zmq.Context] # zeromq context to use
_ctxown = None # type: Optional[zmq.Context]
Expand Down Expand Up @@ -674,3 +674,6 @@ def GetPublishedState(self, timeout=None, fireandforget=False):
if rawState is not None:
return json.loads(rawState)
return None


VisionControllerClient = VisionClient
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import typing # noqa: F401 # used in type check

@six.python_2_unicode_compatible
class VisionControllerClientError(Exception):
class VisionClientError(Exception):
_type = None # type: six.text_type # In PY2, it is unicode; in PY3, it is str
_desc = None # type: six.text_type # In PY2, it is unicode; In PY3, it is str

Expand Down Expand Up @@ -37,12 +37,16 @@ def __hash__(self):
return hash((self._type, self._desc))

def __eq__(self, r):
# type: (VisionControllerClientError) -> bool
# type: (VisionClientError) -> bool
return self._type == r._type and self._desc == r._desc

def __ne__(self, r):
# type: (VisionControllerClientError) -> bool
# type: (VisionClientError) -> bool
return self._type != r._type or self._desc != r._desc

class VisionControllerTimeoutError(VisionControllerClientError):
class VisionTimeoutError(VisionClientError):
pass


VisionControllerClientError = VisionClientError
VisionControllerTimeoutError = VisionTimeoutError