Rhinoscript Python3队列和Pubnub

时间:2017-08-30 00:18:07

标签: python queue ironpython pubnub rhino3d

所以最近我一直在尝试使用pip install --target将新模块安装到RhinoScript python中。我正在研究的项目是一台计算机将从我用pygame.midi设置的钢琴中捕获midi,然后通过pubnub将该midi数据传输到运行自定义rhinoscript插件的计算机,该插件将解释数据。

这是我的PubNub界面,我半边复制了一半

from pubnub.pubnub import PubNub
from pubnub.pnconfiguration import PNConfiguration
from pubnub.callbacks import SubscribeCallback
from pubnub.enums import PNOperationType, PNStatusCategory

pnconfig = PNConfiguration()

pnconfig.subscribe_key = 'mysubkey'
pnconfig.publish_key = 'mypubkey'

pubnub = PubNub(pnconfig)

class MySubscribeCallback(SubscribeCallback):
    def status(self, pubnub, status):
        pass
        # The status object returned is always related to subscribe but could contain
        # information about subscribe, heartbeat, or errors
        # use the operationType to switch on different options
        if status.operation == PNOperationType.PNSubscribeOperation \
                or status.operation == PNOperationType.PNUnsubscribeOperation:
            if status.category == PNStatusCategory.PNConnectedCategory:
                print(status)
                # This is expected for a subscribe, this means there is no error or issue whatsoever
            elif status.category == PNStatusCategory.PNReconnectedCategory:
                pass
                # This usually occurs if subscribe temporarily fails but reconnects. This means
                # there was an error but there is no longer any issue
            elif status.category == PNStatusCategory.PNDisconnectedCategory:
                pass
                # This is the expected category for an unsubscribe. This means there
                # was no error in unsubscribing from everything
            elif status.category == PNStatusCategory.PNUnexpectedDisconnectCategory:
                pass
                # This is usually an issue with the internet connection, this is an error, handle
                # appropriately retry will be called automatically
            elif status.category == PNStatusCategory.PNAccessDeniedCategory:
                pass
                # This means that PAM does allow this client to subscribe to this
                # channel and channel group configuration. This is another explicit error
            else:
                pass
                # This is usually an issue with the internet connection, this is an error, handle appropriately
                # retry will be called automatically
        elif status.operation == PNOperationType.PNSubscribeOperation:
            # Heartbeat operations can in fact have errors, so it is important to check first for an error.
            # For more information on how to configure heartbeat notifications through the status
            # PNObjectEventListener callback, consult <link to the PNCONFIGURATION heartbeart config>
            if status.is_error():
                pass
                # There was an error with the heartbeat operation, handle here
            else:
                pass
                # Heartbeat operation was successful
        else:
            pass
            # Encountered unknown status type

    def presence(self, pubnub, presence):
        pass  # handle incoming presence data

    def message(self, pubnub, message):
        print(message.message)

pubnub.add_listener(MySubscribeCallback())

def publish_callback(result, status):
    pass
    # Handle PNPublishResult and PNStatus


def publishAMessage():
    while True:
        messageinput = input("what would you like to say:  ")
        pubnub.publish().channel('zanescustomkey').message([messageinput]).async(publish_callback)


pubnub.subscribe().channels('zanescustomkey').execute()


print('reached the end')

当您将其放入RhinoScript时,会出现导入错误

Message: No module named queue
Traceback:
line 6, in <module>, "C:\Program Files\Rhinoceros 5 (64-bit)\Plug-ins\IronPython\Lib\pubnub\pubnub.py"
line 2, in <module>, "C:\Users\zanem\OneDrive\Documents\PubNub\pythontest.py"

在IronPython网站上,基本上就是RhinoScript,他们说它们支持多处理器。你们这里有没有人知道如何将队列导入Rhinoscript,似乎在PubNub或Rhinoscript文档中没有任何关于此的文章。

0 个答案:

没有答案