Beispiel #1
0
class SOAPRepositoryServer(RepositoryServer):

    def __init__(self, repository, host='localhost', port=8080):

        super(SOAPRepositoryServer, self).__init__(repository)

        self.server = SOAPServer((host, port), encoding='utf-8')
        self.server.registerObject(self)

    def startup(self):

        self.server.serve_forever()
Beispiel #2
0
 def run(self):
     """Ejecucion del demonio"""
     sms = sms()
     server = SOAPServer(("localhost", self._port))
     server.registerFunction(sms.sms_send)
     server.registerFunction(sms.info_cel)
     while True:
         try:
             server.serve_forever()
             logger.info("sms daemond started")
         except KeyboardInterrupt:
             logger.info("sms daemond ended")
             exit()
         time.sleep(self._pidfile_timeout)
Beispiel #3
0
def createjob(ticketid, comando):

def calcula(op1,op2,operacao):
        id = createticketid()

        return createticketid()
        op1 = randint(5,90)
        time.sleep(30)
        if operacao == '+':
                return op1 + op2
        if operacao == '-':
                return op1 - op2
        if operacao == '*':
                return op1 * op2
        if operacao == '/':
                return op1 / op2

server = SOAPServer(('localhost',8081))
server.registerFunction(calcula,"ns-calcula","calcula")
server.config.dumpSOAPOut = 1
server.config.dumpSOAPIn = 1
server.serve_forever()
    resultado = ''
    for v in venda.readlines():
        if codigoVenda == v.split("|")[0]:
            exclusao = "Venda deletada."
        else:
            resultado += "".join(v)    
    venda.close()
    venda = open("venda.txt", "w")
    venda.write(resultado)
    venda.close()
    return exclusao


def consultaVendaCliente(codigo_cliente):
    venda = open("venda.txt", "r")
    consulta = False
    for v in venda.readlines():
        if codigo_cliente == v.split("|")[1]:
            consulta = True
    venda.close()
    return consulta
    
    
serv = SOAPServer(("localhost", 8008))
serv.registerFunction(cadastrarVenda)
serv.registerFunction(consultarVenda)
serv.registerFunction(deletarVenda)
serv.registerFunction(consultaVendaCliente)
print "Servidor de vendas inicializado!!!"
serv.serve_forever()
Beispiel #5
0
 def run(self):
     """Ejecucion del demonio"""
     cell = Cell()
     server = SOAPServer(("localhost", 8580))
     server.registerFunction(cell.detectar_dispositivos)
     server.registerFunction(cell.listar_forwarding)
     server.registerFunction(cell.remover_forwarding)
     server.registerFunction(cell.agregar_forwarding)
     server.registerFunction(cell.detener_servicio)
     server.registerFunction(cell.iniciar_servicio)
     server.registerFunction(cell.port)
     while True:
         try:
             cell.config_file = configfile
             server.serve_forever()
             logger.info("deviceCelldaemond started")
         except KeyboardInterrupt:
             logger.info("deviceCelldaemond ended")
             exit()
         time.sleep(self._pidfile_timeout)
# required modules
#   * m2crypto
#   * SOAPpy
#       - fpconst
#       - pyXML
#
# required software
#   * openssl
#
# for creating the keys and certificates
#
#   openssl genrsa -out ~/.sslstuff/priv_rsa_key
#   openssl req -new -x509 -key ~/.sslstuff/priv_rsa_key -out ~/.sslstuff/cacert.pem -days 1
#
from SOAPpy import SOAPServer

from M2Crypto import SSL

def greeting(s):
    return 'Hello ' + s

def echo(s):
    return s+s # repeats a string twice

ssl_context = SSL.Context()
ssl_context.load_cert('/home/michael/.sslstuff/cacert.pem', keyfile='/home/michael/.sslstuff/priv_rsa_key')

server = SOAPServer(("localhost",8443), ssl_context = ssl_context)
server.registerFunction(echo)
server.serve_forever()
Beispiel #7
0
                    v.write(line)
            v.close()
            return True
    except:
        return False


#método retornando 0 para sem vendas e 1 para com vendas
def verificaSeExisteVendaParaFuncionario(codigoFuncionario):
    try:
        linhas = open(db, 'r').read()
        f = open(db, "r")
        linhas = f.readlines()
        for linha in linhas:
            codigo_venda, codigo_cliente, codigo_funcionario, data, valor_total, codigo_produto, quantidade = linha.split(
                '|')
            if codigoFuncionario == codigo_funcionario:
                return True
        f.close()
        return False
    except:
        return False


serv = SOAPServer(("localhost", 8009))
serv.registerFunction(cadastrarVenda)
serv.registerFunction(consultarVenda)
serv.registerFunction(deletarVenda)
serv.registerFunction(verificaSeExisteVendaParaFuncionario)

serv.serve_forever()
Beispiel #8
0
       f.close()

       f = open(db, "w")
       for linha in linhas:
              codigo, nome, endereco, sexo, datanascimento = linha.split ('|')
              if codigo != codigoFuncionario:
                    f.write(linha)
       f.close()

       return True
  except:
    return False    

       

def listaFuncionario():
  try:
    f = open(db, "r")
    linhas = f.readlines()
    return linhas
  except:
    return False

serv = SOAPServer(("localhost", 8008))

serv.registerFunction(consultaFuncionario)
serv.registerFunction(cadastraFuncionario)
serv.registerFunction(listaFuncionario)
serv.registerFunction(deletaFuncionario)

serv.serve_forever() 
Beispiel #9
0
		linhas = open(db,'r').read()
		f = open(db,"r")
		linhas = f.readlines()

		for linha in linhas:
			codigoCompra_, codigoProduto, quantidade, data, valortotal, codigoForn = linha.split('|')
			if codigoForn == codigoFornecedor:
				print'achou'
				return True

		f.close()

		return False

	except:
		return False




serv = SOAPServer(("localhost", 8007))

serv.registerFunction(consultarCompra)
serv.registerFunction(cadastrarCompra)
serv.registerFunction(deletarCompra)
serv.registerFunction(consultaFornecedorExisteCompra)


serv.serve_forever()

from SOAPpy import SOAPServer

produtos = {"codigo":"0001","descricao":"Coca-Cola","preco":"3.80","saldo":"50","estoque":"1"}

def saldoProduto(codigo,estoque):
    if produtos["codigo"] == codigo and produtos["estoque"] == estoque:
        return produtos["saldo"]
    else:
        return "Produto inexistente!"

def descricaoProduto(codigo):
    if produtos["codigo"] == codigo:
        return produtos["descricao"]
    else:
        return "Produto inexistente!"

def precoProduto(codigo):
    if produtos["codigo"] == codigo:
        return produtos["preco"]
    else:
        return "Produto inexistente!"

server = SOAPServer(("localhost", 8080))

server.registerFunction(saldoProduto)
server.registerFunction(descricaoProduto)
server.registerFunction(precoProduto)

server.serve_forever()
Beispiel #11
0
from SOAPpy import SOAPServer
from pprint import pprint


def convert(temperature, scale):
    if scale == "C":
        response = {"temperature": 9.0 / 5.0 * temperature + 32, "scale": "F"}
    else:
        response = {
            "temperature": (temperature - 32) * 5.0 / 9.0,
            "scale": "C"
        }
    pprint(response)
    return response


server = SOAPServer(('localhost', 8081))
server.registerFunction(convert)
server.serve_forever()
	arquivos = open(banco,'r').read().split('\n')
	for arquivo in arquivos:        
		if arquivo == '':
			print "Vazio"
			break
		codigo,nome,contato = arquivo.split('|')
		dic = {}
		dic['codigo'] = codigo
		dic['nome'] = nome
		dic['contato'] = contato
		if dic['codigo'] == codigo1:
			return dic.items()
	

def deletaCliente(codigoCliente):
#	Procurar onde está o proxy vendas	
#	if cod true
#		return false
	if consultaCliente(codigoCliente):
		return False
	arquivos = open(banco,'r').read().split('\n')
	for line in arquivos:
		


serv = SOAPServer(("localhost", 8005))
serv.registerFunction(cadastrar)
serv.registerFunction(consultaCliente)
serv.serve_forever()

#encoding:utf-8

from SOAPpy import SOAPServer
from Funcionario import Funcionario

func = Funcionario("funcionarios.txt")

srv = SOAPServer(("localhost",8087))
srv.registerFunction(func.cadastrarFuncionario)
srv.registerFunction(func.consultarFuncionario)
srv.registerFunction(func.deletarFuncionario)
srv.serve_forever()
        if codigoProduto == p.split(",")[0]:
            consulta = p.split(",")
    return consulta

def consultarCliente(codigoCliente):
    cliente = open("cliente.txt", "r")
    consulta = None
    for c in cliente.readlines():
        if codigoCliente == c.split(",")[0]:
            consulta = c.split(",")
    return consulta

def consultarFuncionario(codigoFuncionario):
    funcionario = open("funcionario.txt", "r")
    consulta = None
    for f in funcionario.readlines():
        if codigoFuncionario == f.split(",")[0]:
            consulta = f.split(",")
    return consulta

    
    
serv = SOAPServer(("localhost", 8000))
serv.registerFunction(consultaProduto)
serv.registerFunction(consultarCliente)
serv.registerFunction(consultarFuncionario)
print "server all inicializado..."
serv.serve_forever()


Beispiel #15
0
        return {"estado": True, "dispositivo":datos}
        








if __name__ == "__main__":
    try:
        cell = Cell()
        #print(cell.detectar_dispositivos())
        #print(cell.agregar_forwarding(3390))
        #print(cell.listar_forwarding())
        #print(cell.remover_forwarding())
        #print(cell.listar_forwarding())
        server = SOAPServer(("localhost",8580))
        server.registerFunction(cell.detectar_dispositivos)
        server.registerFunction(cell.listar_forwarding)
        server.registerFunction(cell.remover_forwarding)
        server.registerFunction(cell.agregar_forwarding)
        server.registerFunction(cell.detener_servicio)
        server.registerFunction(cell.iniciar_servicio)
        server.serve_forever()
        
    except KeyboardInterrupt:
        print(u"Finalizada la aplicación")
        sys.exit()
 def run(self):
     """Ejecucion del demonio"""
     cell = Cell()
     server = SOAPServer(("localhost",8580))
     server.registerFunction(cell.detectar_dispositivos)
     server.registerFunction(cell.listar_forwarding)
     server.registerFunction(cell.remover_forwarding)
     server.registerFunction(cell.agregar_forwarding)
     server.registerFunction(cell.detener_servicio)
     server.registerFunction(cell.iniciar_servicio)
     server.registerFunction(cell.port)
     while True:
         try:
             cell.config_file = configfile         
             server.serve_forever()
             logger.info("deviceCelldaemond started")
         except KeyboardInterrupt:
             logger.info("deviceCelldaemond ended")
             exit()
         time.sleep(self._pidfile_timeout)
from SOAPpy import SOAPServer
import psycopg2
import psycopg2.extras
import sys

import os

import commands

db = __import__(sys.argv[1])

Model = db.Model()

#from mongo import *
	
server = SOAPServer(('localhost',8081))

server.registerObject(Model)
#server.registerFunction(Model.insereOrgao)
#server.registerFunction(Model.listaOrgao)
#server.registerFunction(Model.insereEmpregado)
#server.registerFunction(Model.listaEmpregados)
#server.registerFunction(Model.listaDependentes)
#server.registerFunction(Model.insereDependente)
#server.registerFunction(Model.insereDocEmpregado)
#server.registerFunction(Model.insereDocDependente)




server.serve_forever()
Beispiel #18
0
		
        date_tag = ET.Element('date')
        day_tag = ET.Element('day')
        day_tag.text = day
        month_tag = ET.Element('month')
        month_tag.text = month
        year_tag = ET.Element('year')
        year_tag.text = year
        date_tag.append(day_tag)
        date_tag.append(month_tag)
        date_tag.append(year_tag)
		
        new_tag.append(name_tag)
        new_tag.append(types_tag)
        new_tag.append(stars_tag)
        new_tag.append(director_tag)
        new_tag.append(date_tag)
		new_tag.append(time_tag)
		new_tag.append(resolution_tag)
		
        root.insert(0,new_tag)
        tree.write('MovieAll_SPN.xml')

print "start"
server = SOAPServer(("localhost", 8081))
server.registerObject(webservice(), "xml")
server.serve_forever()



Beispiel #19
0
from SOAPpy import SOAPServer
from omniORB import CORBA, PortableServer
import CosNaming, MainServer, MainServer__POA
import server_client_side as client_side

connection = pika.BlockingConnection(
    pika.ConnectionParameters(host='localhost'))
channel = connection.channel()


# Cria a fila de mensagens para o usuário
def create_queue(user_name):
    channel.queue_declare(queue=user_name)


soap_server = SOAPServer(('localhost', 8081))
soap_server.registerFunction(create_queue)


def server_run():
    soap_server.serve_forever()


# Executa o webservice em uma thread, pois o processo é bloqueante
go_server = Thread(target=server_run)
go_server.daemon = True
go_server.start()


class MainServer(MainServer__POA.Server):
    users = []  # [[username, obj], [username, obj], [username, obj]...]
Beispiel #20
0
from SOAPpy import SOAPServer


def minus(m, n):
    return m - n


def multi(m, n):
    return m * n


server = SOAPServer(("0.0.0.0", 2010))
server.registerFunction(minus)
server.registerFunction(multi)
server.serve_forever()
#!/usr/bin/env python
#-*- encoding: iso-8859-1 -*-

from SOAPpy import SOAPServer
from produto import Produto


def cadastrarProduto(descricao, preco, codigoFornecedor):
    produto1 = Produto()
    return produto1.cadastrarProduto(descricao, preco, codigoFornecedor)


def deletarProduto(codigoProduto):
    produto2 = Produto()
    return produto2.deletarProduto(codigoProduto)


serv = SOAPServer(("localhost", 8080))
serv.registerFunction(cadastrarProduto)
serv.registerFunction(deletarProduto)

serv.serve_forever()

Beispiel #22
0
            conf['accesstoken'],
            conf['accesstokensecret'],
            conf['consumerkey'],
            conf['consumersecret']
        )
    )
    print '%s Tweeting: %r' % (datetime.datetime.now(), tweet)
    try:
        t.statuses.update(status=tweet)
        print '%s Done!' % (datetime.datetime.now())
    except Exception, e:
        print '%s Failed: %s' % (datetime.datetime.now(), e)

def commit(Array):
    data = dict(zip(('version', 'repoid', 'checksum', 'rev', 'paths', 'log', 'author', 'branch', 'module'), Array))
    repoid = data['repoid']
    if repoid in config['repos']:
        if checkpassword(data, config['repos'][repoid]['password']):
            tweet(data, config['repos'][data['repoid']])
        else:
            print '%s got wrong password!' % (datetime.datetime.now())
            return "wrong password"

    return "OK"

if __name__=='__main__':
    config = json.loads(file('config.json').read())
    server = SOAPServer((config['host'], config['port']))
    server.registerFunction(commit, config['namespace'])
    server.serve_forever()
Beispiel #23
0
    try:
        linhas = open(db, 'r').read()
    except:
        return False
    retorno = 'teste'
    for linha in linhas.split('\n'):
        retorno = retorno + linha
    return retorno


def consultaEstoque(codigoEstoque):
    try:
        linhas = open(db, 'r').read()
    except:
        return False
    retorno = 'Produto nao encontrado'
    for linha in linhas.split('\n'):
        estoque = linha.split('|')
        if (estoque[0] == codigoEstoque):
            retorno = estoque[1] + ' com codigo ' + estoque[
                0] + ' localizacao' + estoque[2]
    return retorno


serv = SOAPServer(("localhost", 8001))

serv.registerFunction(cadastrarEstoque)
serv.registerFunction(deleteEstoque)
serv.registerFunction(listaEstoque)
serv.registerFunction(consultaEstoque)
serv.serve_forever()
Beispiel #24
0
	def __init__(self, ipVersion):
		ssl_context = SSL.Context()
		ssl_context.load_cert(certfile='ca.pem', keyfile='ca.key')
		SOAPServer.__init__(("localhost", C.NETCONF_SOAPHTTP_PORT), ssl_context = ssl_context)
Beispiel #25
0
def login(user):
    try:
        linhas = open(db,'r').read()
    except:
        return False
    
    for linha in linhas.split('\n'):
        
        if linha == '':
           break 
        user1,passwd = linha.split('|')
        if user['usuario'] == user1 and user['senha'] == passwd:
            return True
    return False

#def registra(usuario,senha):
def registra(user):
    if login(user):
        return False
    conexao = open(db,'a')
    conexao.write('%s|%s\n' % (user['usuario'],user['senha']))
    conexao.close()
    return True

serv = SOAPServer(("localhost", 8080))

serv.registerFunction(login)
serv.registerFunction(registra)

serv.serve_forever()
                movie.find('resolution').text = res
                tree.write('MovieAll_SPN.xml')
                break
        return "resolution edited"

    def addInitLength(self, length):
        tree = ET.parse('MovieAll_SPN.xml')
        root = tree.getroot()
        for movie in root.findall('movie'):
            len_tag = ET.Element('length')
            len_tag.text = length
            movie.append(len_tag)
        tree.write('MovieAll_SPN.xml')
        return "movie length added"

    def editLength(self, name, length):
        tree = ET.parse('MovieAll_SPN.xml')
        root = tree.getroot()
        for movie in root.findall('movie'):
            if movie.find('name').text == name:
                movie.find('length').text = length
                tree.write('MovieAll_SPN.xml')
                break
        return "length edited"


print "start"
server = SOAPServer(("172.31.23.46", 8081))
server.registerObject(webservice(), "xml")
server.serve_forever()
Beispiel #27
0
    except:
        return False


def deletarAreceber(codigoR):
    try:
        servico = SOAPProxy("http://localhost:8011")

        f = open(db, "r")
        lines = f.readlines()
        f.close()

        f = open(db, "w")
        for linha in linhas:
            codigoAreceber, codigoVenda, dataVencimento, dataPagamento, status = linha.split(
                '|')
            if codigoAreceber != codigoR:
                f.write(linha)
        f.close()
        return True
    except:
        return False


serv = SOAPServer(("localhost", 8011))

serv.registerFunction(ContasArecebe)
serv.registerFunction(consultarAreceber)
serv.registerFunction(deletarAreceber)
serv.serve_forever()
from SOAPpy import SOAPServer
import psycopg2
import psycopg2.extras

import os

import commands

from postgres_dict import *

def hello():
	return 'hello world'
	
def tchau():
	print 'Adeus'
	
server = SOAPServer(('localhost',8081))

server.registerFunction(hello)
server.registerFunction(listaEmpregados)

servidores = listaEmpregados(id_empregado = 7)

for servidor in servidores:
	print servidor['no_empregado']

server.serve_forever()
Beispiel #29
0
def login(user):
    try:
        linhas = open(db, 'r').read()
    except:
        return False

    for linha in linhas.split('\n'):

        if linha == '':
            break
        user1, passwd = linha.split('|')
        if user['usuario'] == user1 and user['senha'] == passwd:
            return True
    return False


def registra(user):
    if login(user):
        return False
    conexao = open(db, 'a')
    conexao.write('%s|%s\n' % (user['usuario'], user['senha']))
    conexao.close()
    return True


serv = SOAPServer(("localhost", 8080))

serv.registerFunction(login)
serv.registerFunction(registra)
serv.serve_forever()
Beispiel #30
0
from SOAPpy import SOAPServer
import random

tabuleiro = []


def sorteio(n_bolas, terminal):

    if terminal == 1:
        bola = random.randrange(1, n_bolas + 1, 1)
        while bola in tabuleiro:
            bola = random.randrange(1, n_bolas, 1)

        tabuleiro.append(bola)
        return "bola " + str(bola) + " inserida no tabuleiro"
    if terminal == 2:
        texto = "Bolas sorteadas:"
        for i in tabuleiro:
            texto = texto + str(i) + ' '

        return texto
    if terminal == 3:
        for i in tabuleiro:
            tabuleiro.pop()
        tabuleiro.pop()
        return "Tabuleiro reiniciado"


server = SOAPServer(('localhost', 8081))
server.registerFunction(sorteio)
server.serve_forever()
#coding: utf-8

from SOAPpy import SOAPServer


def calcula(op1, op2, operacao):
    if operacao == '+':
        return op1 + op2
    if operacao == '-':
        return op1 - op2
    if operacao == '*':
        return op1 * op2
    if operacao == '/':
        return op1 / op2


server = SOAPServer(('localhost', 8081))
server.registerFunction(calcula)
server.serve_forever()  #processa uma ou várias solicitações.
Beispiel #32
0

def saldoProduto(codigo, estoque):
    if produtos["codigo"] == codigo and produtos["estoque"] == estoque:
        return produtos["saldo"]
    else:
        return "Produto inexistente!"


def descricaoProduto(codigo):
    if produtos["codigo"] == codigo:
        return produtos["descricao"]
    else:
        return "Produto inexistente!"


def precoProduto(codigo):
    if produtos["codigo"] == codigo:
        return produtos["preco"]
    else:
        return "Produto inexistente!"


server = SOAPServer(("localhost", 8080))

server.registerFunction(saldoProduto)
server.registerFunction(descricaoProduto)
server.registerFunction(precoProduto)

server.serve_forever()
Beispiel #33
0
# -*- coding: utf-8 -*-

from SOAPpy import SOAPServer, SOAPProxy
from models import ProdutoNoEstoque, EstoqueFoiUsado, PrecoDoProduto

server = SOAPServer(("localhost", 8004))

def inserir_produto_no_estoque(codigo_estoque, codigo_produto, quantidade):
    return ProdutoNoEstoque(
        codigo_estoque=codigo_estoque,
        codigo_produto=codigo_produto,
        quantidade=quantidade
    ).salvar()

def consultar_produto_em_estoque(codigo_produto, codigo_estoque):
    return ProdutoNoEstoque.verificar_quantidade(codigo_produto, codigo_estoque)

def consultar_estoque_em_produto_estoque(codigo_estoque):
    return EstoqueFoiUsado(codigo_estoque).verificar()

def pesquisar_preco_do_produto(codigo_produto):
    return PrecoDoProduto(codigo_produto).consultar()

server.registerFunction(inserir_produto_no_estoque,
    funcName='inserirProdutoEstoque')
server.registerFunction(consultar_produto_em_estoque,
    funcName='consultaProdutoEmEstoque')
server.registerFunction(consultar_estoque_em_produto_estoque,
    funcName='consultaEstoqueEmProdutoEstoque')
server.registerFunction(pesquisar_preco_do_produto,
    funcName='pesquisaPrecoProduto')
Beispiel #34
0
        f = open(db, "w")
        for linha in linhas:
            codigoComissao, codigoFuncionario, ano, mes, valor = linha.split(
                '|')
            if codigoFuncionario != pcodigoFun:
                f.write(linha)
        f.close()
        return True
    except:
        return False


def listaComissao():
    try:
        linhas = open(db, 'r').read()
        f = open(db, "r")
        linhas = f.readlines()
        return linhas
    except:
        return False


serv = SOAPServer(("localhost", 8012))

serv.registerFunction(cadastraComissao)
serv.registerFunction(consultarComissaoFuncionario)
serv.registerFunction(deletaComissaoFuncionario)
serv.registerFunction(listaComissao)
serv.registerFunction(calcularComissao)
serv.serve_forever()
Beispiel #35
0
#	
#def listarVenda():
#	try:
#		conexao_r = open(db,"r")
#		vendas_linhas = conexao_r.readlines()
#		conexao_r.close()
#		return vendas_linhas
#	except:
#		return False

def consultarCliente(codigoCliente):
	try:	
		servico_venda = SOAPProxy("http://localhost:8009")
		vendas_linhas = servico_venda.listarVenda()
		
		for vendas_linhas in venda_linha:
			codigoVenda, codigoClienteVenda, codigoFuncionario, data, valortotal, codigoProduto, quantidadecodigoVenda, codigoCliente, codigoFuncionario, data, valortotal, codigoProduto, quantidade = venda_linha.split('|')
			if codigoClienteVenda == codigoCliente:
				return True
		return False
	except:
		return False

serv = SOAPServer(("localhost", 8006))

serv.registerFunction(cadastraCliente)
serv.registerFunction(deletarCliente)
serv.registerFunction(consultarCliente)

serv.serve_forever()
Beispiel #36
0
                f.close()
                return True

        f.close()

        return False

    except:
        return False


def listarFornecedor():
    try:
        linhas = open(db, 'r').read()
        f = open(db, "r")
        linhas = f.readlines()
        f.close()
        return linhas
    except:
        return False


serv = SOAPServer(("localhost", 8005))

serv.registerFunction(consultaFornecedor)
serv.registerFunction(cadastraFornecedor)
serv.registerFunction(deletarFornecedor)
serv.registerFunction(listarFornecedor)

serv.serve_forever()
Beispiel #37
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__docformat__ = 'restructuredtext en'
#!/usr/bin/env python
# encoding:utf-8
from SOAPpy import SOAPServer


def echo(s):
    return s  # repeats a string twice


server = SOAPServer(("0.0.0.0", 8080))
server.registerFunction(echo)
server.serve_forever()

# vim:set et sts=4 ts=4 tw=80:
from SOAPpy import SOAPServer
db = 'Funcionario.txt'
def consultarFuncionario(codigoFuncionario):
    try:
        linhas = open(db,'r').read()
    except:
        return False
    
    for linha in linhas.split('\n'):
        
        if linha == '':
           break 
        codigoFuncionario,nome,endereco,sexo,datanascimento = linha.split('|')
        if codigoFuncionario['codigoFuncionario'] == codigoFuncionario:
            return True
    return False

def cadastrarFuncionario(Funcionario):
    if consultarFuncionario(Funcionario):
        return False
    conexao = open(db,'a')
    conexao.write('%d|%s|%s|%s|%s\n' %(funcionario['codigoFuncionario'],nome['nome'], endereco['endereco'],sexo['sexo'],datanascimento['datanascimento']))
    conexao.close()
    return True

serv = SOAPServer(("localhost", 8080))
serv.registerFunction(consultarFuncionario)
serv.registerFunction(cadastrarFuncionario)

serv.serve_forever()
Beispiel #39
0
            codigo, descricao, localizacao = linha.split('|')
            if codigoFabricante == codigo:
                return True

        f.close()

        return False

    except:
        return False


def listaFabricantes():
    try:
        linhas = open(db, 'r').read()
        f = open(db, "r")
        linhas = f.readlines()
        return linhas
    except:
        return False


serv = SOAPServer(("localhost", 8082))

serv.registerFunction(consultaFabricante)
serv.registerFunction(cadastraFabricante)
serv.registerFunction(deleteFabricante)
serv.registerFunction(listaFabricantes)

serv.serve_forever()
Beispiel #40
0
#!/usr/bin/env python2.4

import sys
from SOAPpy import SOAPServer

WS_NS = 'http://frade.no-ip.info/wsFOAF'


class foafWS:
    def test(self):
        return "Cadena de prueba"

    def getFoaf(self, chain):
        return "http://www.wikier.org/foaf.rdf"


server = SOAPServer(('', 8880))
ws = foafWS()

server.registerObject(ws, WS_NS)

print "Starting server..."
server.serve_forever()
Beispiel #41
0
    t = Twitter(auth=OAuth(conf['accesstoken'], conf['accesstokensecret'],
                           conf['consumerkey'], conf['consumersecret']))
    print '%s Tweeting: %r' % (datetime.datetime.now(), tweet)
    try:
        t.statuses.update(status=tweet)
        print '%s Done!' % (datetime.datetime.now())
    except Exception, e:
        print '%s Failed: %s' % (datetime.datetime.now(), e)


def commit(Array):
    data = dict(
        zip(('version', 'repoid', 'checksum', 'rev', 'paths', 'log', 'author',
             'branch', 'module'), Array))
    repoid = data['repoid']
    if repoid in config['repos']:
        if checkpassword(data, config['repos'][repoid]['password']):
            tweet(data, config['repos'][data['repoid']])
        else:
            print '%s got wrong password!' % (datetime.datetime.now())
            return "wrong password"

    return "OK"


if __name__ == '__main__':
    config = json.loads(file('config.json').read())
    server = SOAPServer((config['host'], config['port']))
    server.registerFunction(commit, config['namespace'])
    server.serve_forever()