Python:在全球破坏期间不会破坏传播者

时间:2017-01-04 11:11:33

标签: python sys ice

当我尝试使用:

执行以下python脚本时
  

的/ usr /斌/蟒   /var/www/html/iPhone/inarrivo/python/addMurmurChannel.py 14   我收到错误:   在全球破坏期间没有被破坏的传播者。

什么是沟通者以及我如何摧毁它?

#!/usr/bin/python
import Ice
import inspect
import sys
#Ice.loadSlice("/usr/local/murmur/ice/Murmur.ice")
Ice.loadSlice( '', ['-I' + Ice.getSliceDir(), "/usr/local/murmur/ice/Murmur.ice"])
import Murmur
newChannelName=sys.argv[1]
# Init ice
comm = Ice.initialize()
# Let Ice know where to go to connect to mumble
# Let Ice know where to go to connect to mumble
proxy = comm.stringToProxy("Meta -e 1.0:tcp -p 6502")
# Create a dynamic object that allows us to get a programmable interface for Mumble
meta = Murmur.MetaPrx.checkedCast(proxy)
# Get the server instance from the set of servers.
server = meta.getServer(1)
found=False
channels = server.getChannels()
for value in channels.itervalues():
    idChannel=value.id
    if value.name == newChannelName:
            found=True
            break
if found==False:
    server.addChannel(newChannelName, 0)

1 个答案:

答案 0 :(得分:0)

致电

ic = Ice.initialize()

创建了一个沟通者。 你可以像这样摧毁它:

if ic:
    # Clean up
    try:
        ic.destroy()
    except:
        traceback.print_exc()
        status = 1

参考:https://doc.zeroc.com/display/Ice36/Writing+an+Ice+Application+with+Python#WritinganIceApplicationwithPython-WritingaClientinPython