Exemplo n.º 1
0
    def test_should_issue_hello_world_message(self):
        out = mock()

        hello_world = HelloWorld()
        hello_world.helloworld(out)

        verify(out).write("Hello world of Python\n")
Exemplo n.º 2
0
def main():
    try:
        # Make socket
        transport = TSocket.TSocket('127.0.0.1', 30303)

        # Buffering is critical. Raw sockets are very slow
        transport = TTransport.TBufferedTransport(transport)

        # Wrap in a protocol
        protocol = TBinaryProtocol.TBinaryProtocol(transport)

        # Create a client to use the protocol encoder
        client = HelloWorld.Client(protocol)

        # Connect!
        transport.open()

        client.ping()
        print("ping()")

        msg = client.sayHello()
        print(msg)
        msg = client.sayMsg('HELLO_WORLD')
        print(msg)
        transport.close()
    except Thrift.TException as e:
        print("%s" % (e.message))
def main(port):
    addr = 'tcp://127.0.0.1:' + port
    server = Server()
    server.register(HelloWorld())
    s = zerorpc.Server(server)
    s.bind(addr)
    print("start running on {}".format(addr))
    s.run()
Exemplo n.º 4
0
 def test_gen_tasks(self):
     hw = HelloWorld()
     hw.site = MockObject()
     hw.site.config = {}
     for i in hw.gen_tasks():
         self.assertEqual(i['basename'], 'hello_world')
         self.assertEqual(i['uptodate'], [False])
         try:
             self.assertIsInstance(i['actions'][0][1][0], bool)
         except AttributeError:
             LOGGER.warning('Python 2.6 is missing assertIsInstance()')
Exemplo n.º 5
0
        results = pygn.createRadio(clientID,
                                   userID,
                                   artist='',
                                   track='',
                                   mood=moodid,
                                   popularity='1000',
                                   similarity='1000',
                                   count='2')
        output = "Song for " + keyword + ":\n"
        if results == None:
            output = 'No available tracks in databases'
        for result in results:
            output += 'Track title: ' + result[
                'track_title'] + ', Artist: ' + result['album_artist_name']
        ret = "Received: " + output
        print(ret)
        return ret


handler = HelloWorldHandler()
processor = HelloWorld.Processor(handler)
transport = TSocket.TServerSocket("localhost", 9090)
tfactory = TTransport.TBufferedTransportFactory()
pfactory = TBinaryProtocol.TBinaryProtocolFactory()

server = TServer.TSimpleServer(processor, transport, tfactory, pfactory)

print("Starting thrift server in python...")
server.serve()
print("done!")
Exemplo n.º 6
0
from thrift.transport import TSocket
from thrift.transport import TTransport
from thrift.protocol import TBinaryProtocol

try:
    # Make socket
    transport = TSocket.TSocket('127.0.0.1', 30303)

    # Buffering is critical. Raw sockets are very slow
    transport = TTransport.TBufferedTransport(transport)

    # Wrap in a protocol
    protocol = TBinaryProtocol.TBinaryProtocol(transport)

    # Create a client to use the protocol encoder
    client = HelloWorld.Client(protocol)

    # Connect!
    transport.open()

    client.ping()
    print "ping()"

    msg = client.sayHello()
    print msg
    msg = client.sayMsg(HELLO_IN_KOREAN)
    print msg

    transport.close()
except Thrift.TException, tx:
    print "%s" % (tx.message)
    def test_reader_function(self):

        hw = HelloWorld(name="Foo Bar")
        msg = hw.say_hello()

        self.assertEqual(msg, "Hello Foo Bar!!")
Exemplo n.º 8
0
import sys
from helloworld import HelloWorld
from PyQt5.QtWidgets import QApplication

if __name__ == "__main__":
    a = QApplication(sys.argv)
    w = HelloWorld()
    w.show()
    # sys.exit(a.exec_())

    try:
        sys.exit(a.exec_())
    except SystemExit:
        pass
    except:
        pass
Exemplo n.º 9
0
 def test_hello_world(self):
     hello_world = HelloWorld.HelloWorld()
     hello_world.set_age(5)
     hello_world.age_one_year()
     self.assertEqual(6, hello_world.get_age())
Exemplo n.º 10
0
 def website(self):
     from helloworld import HelloWorld
     return HelloWorld()
Exemplo n.º 11
0
from helloworld import HelloWorld, HelloWorld2

hw = HelloWorld()
r1 = 2
r2 = 3
hw.set(r1, r2)
s = hw.get()
print("Hello, World! sin({} + {}) = {}".format(r1, r2, s))
hw.print_()

hw2 = HelloWorld2()
hw2.set(r1, r2)
s = hw2.gets()
print("Hello, World2! sin({} + {}) = {}".format(r1, r2, s))