本文整理汇总了Python中server.main函数的典型用法代码示例。如果您正苦于以下问题:Python main函数的具体用法?Python main怎么用?Python main使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了main函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main():
for a in sys.argv:
if a == '-v':
print_version_and_exit()
if len(sys.argv) < 2 or sys.argv[1] == '-h':
print_usage_and_exit(0)
load_settings()
command = sys.argv[1]
arg_parser = make_arg_parser(command)
import relayevent
import sendmail
import server
import webhook
if command in ('startserver', 'stopserver'):
server.main(arg_parser, sys.argv[2:], command[:-6])
elif command == 'sendmail':
sendmail.main(arg_parser, sys.argv[2:])
elif command == 'relayevent':
relayevent.main(arg_parser, sys.argv[2:])
elif command == 'webhook':
webhook.main(arg_parser, sys.argv[2:])
else:
sys.stderr.write('unknown command "%s"\n\n' % command)
print_usage_and_exit(-1)
开发者ID:thunderace,项目名称:motioneye,代码行数:33,代码来源:meyectl.py
示例2: update
def update(self, clickPos, page, serverAddr=""):
"""
option 1: 1p vs 1p
option 2: connect
option 3: server
option 4: client
option 5: server address correct or not
"""
if self.rect.collidepoint(clickPos):
if self.option == 1:
pygame.quit()
mainScreen.main()
elif self.option == 2:
page[0] = 2
elif self.option == 3:
pygame.quit()
server.main()
elif self.option == 4:
page[0] = 3
elif self.option == 5:
ifCorrect = checkAddressFormat(serverAddr)
if ifCorrect:
pygame.quit()
client.main(serverAddr)
else:
page[0] = -1
开发者ID:Ping-Lin,项目名称:PikaBall_Connect,代码行数:26,代码来源:menuButton.py
示例3: main
def main():
print "Launched."
if not os.path.exists("dataSaved.csv"):
try:
f = open("dataSaved.csv", "w")
except IOError:
print "Unable to create CSV file. Exiting."
return
else:
f.close()
v = Verarbeitung()
v.loadData()
v.saveDataCSV()
t = Thread(target=application.realmain)
t.start()
print "Web server launched!"
try:
print "About to launch local server..."
server.main(v)
except KeyboardInterrupt:
pass
finally:
print "Exiting. Saving data."
v.saveData()
t._Thread__stop()
开发者ID:hugoR23,项目名称:Sensor-BeagleBone-Project,代码行数:29,代码来源:main.py
示例4: test_main
def test_main():
fakemodule = FakeSocketModule()
success = False
try:
server.main(fakemodule)
except AcceptCalledMultipleTimes:
success = True
assert success, "something went wrong"
开发者ID:phammin1,项目名称:cse491-serverz,代码行数:10,代码来源:test_imageapp.py
示例5: start
def start():
for d in DIRS:
if not os.path.exists(os.getcwd() + '/' + d):
print 'This is not a drax project, directory "{}"'\
' is missing'.format(d)
return
parser = argparse.ArgumentParser()
parser.add_argument('--port', default=8888)
parser.add_argument('--auth_token', default=None)
args = parser.parse_args(sys.argv[2:])
server.main(os.getcwd(), auth_token=args.auth_token, port=args.port)
开发者ID:ss12344,项目名称:drax,代码行数:11,代码来源:commands.py
示例6: main
def main(argv=None):
program_name = os.path.basename(sys.argv[0])
program_version = __version__
program_build_date = "%s" % __updated__
program_version_string = '%%prog %s (%s)' % (program_version, program_build_date)
program_longdesc = '''''' # optional - give further explanation about what the program does
program_license = u"Copyright 2016 Magosányi Árpád \
Licensed under GNU GPL v3"
if argv is None:
argv = sys.argv[1:]
try:
parser = OptionParser(version=program_version_string, epilog=program_longdesc, description=program_license)
parser.add_option("-d", "--id", dest="keyid", type="string",
help="key id (mandatory!)")
parser.add_option("-m", "--module", dest="module", type="string",
help="pkcs11 module path")
parser.add_option("-p", "--pin", dest="pin", type="string",
help="pin [default: %default]")
parser.add_option("-M", "--mechanism", dest="mechanism",
help="HNAC/sign mechanism to use [default: %default]", type="string")
parser.add_option("-H", "--host", dest="host", type="string",
help="host [default: %default]")
parser.add_option("-P", "--port", dest="port", type="int",
help="port [default: %default]")
parser.add_option("-v", "--verbose", dest="verbose", action="count",
help="verbose to syslog. WARNING: logs PIN! [default: %default]")
parser.add_option("-e", "--environment", dest="environment", type="string",
help="append var=value to environment [default: %default]")
parser.set_defaults(module="/usr/lib/opensc-pkcs11.so", pin=u"0000", mechanism="SHA512-RSA-PKCS", host=u"localhost", port=9999, environment=None)
# process options
(opts, args) = parser.parse_args(argv)
if not opts.keyid:
print parser.format_help()
sys.exit(1)
if opts.environment:
(name,value) = opts.environment.split("=",2)
print (name,value)
os.environ[name]=value
syslog.openlog("cryptoserver", logoption=syslog.LOG_PID)
syslog.syslog("cryptoserver started at {0} {1}".format(opts.host,opts.port))
server.main(opts)
except:
excString = traceback.format_exc()
syslog.syslog(excString)
print excString
syslog.syslog("cryptoserver stopped at {0} {1}".format(opts.host,opts.port))
开发者ID:krosza,项目名称:PDAnchor,代码行数:53,代码来源:cryptoserver.py
示例7: main
def main():
if len(sys.argv) != 2:
usage()
sys.exit(1)
if sys.argv[1] == 'serve':
server.main()
elif sys.argv[1] == 'crawl':
crawler.main()
else:
usage()
sys.exit(1)
开发者ID:GTLL,项目名称:Planet-GTLL,代码行数:12,代码来源:__init__.py
示例8: test_main
def test_main():
fakemodule = FakeSocketModule()
sys.argv[1] = '-A'
sys.argv.append('myapp')
success = False
try:
server.main(fakemodule)
except AcceptCalledMultipleTimes:
success = True
pass
assert success, "Something went wrong"
开发者ID:leflerja,项目名称:cse491-serverz,代码行数:13,代码来源:test_server.py
示例9: startDaemon
def startDaemon():
curPath = os.path.dirname(os.path.realpath(__file__))
# Fork and die
pid = os.fork()
if pid == 0: #The first child
#os.chdir("/")
os.setsid()
os.umask(0)
pid2 = os.fork()
if pid2 == 0:
server.main()
#subprocess.call(["python",curPath + '/server.py'])
sys.exit()
开发者ID:kavod,项目名称:TvShowWatch-2,代码行数:13,代码来源:tvShowWatch.py
示例10: main
def main():
parser = argparse.ArgumentParser()
parser.add_argument("--host", default="0.0.0.0")
parser.add_argument("--port", type=int, default=1155)
parser.add_argument("--mongo_host", default="localhost")
parser.add_argument("--mongo_port", type=int, default=27017)
args = parser.parse_args()
try:
c = Connection()
c.disconnect()
except:
print "mongo connection not found"
exit(1)
server.main(args)
message = '''
开发者ID:wandp,项目名称:Camelot,代码行数:16,代码来源:__init__.py
示例11: main
def main():
desc = "A chat app built over TCP"
parser = argparse.ArgumentParser(description=desc)
group = parser.add_mutually_exclusive_group()
group.add_argument('-s', '--server', action='store_true', help='starts the server')
group.add_argument('-c', '--client', action='store_true', help='starts the client')
parser.add_argument('interface')
parser.add_argument('password')
args = parser.parse_args()
argv = [args.interface, args.password]
if args.server:
server.main(argv)
elif args.client:
client.main(argv)
else:
parser.print_help()
开发者ID:addliu,项目名称:TC,代码行数:17,代码来源:chat.py
示例12: test_create_server_input
def test_create_server_input(self):
"""
Verify the input when creating servers is always correct.
"""
# This case should cast 8080 to an int
sys.argv = ['server.py']
sys.argv.append('-l 127.0.0.1')
sys.argv.append('-p 8080')
self.assertRaises(SystemExit, server.main)
# This case can't cast tasty tacos to integers.
# Make sure we get a parser error and invalid int warning
sys.argv[1] = '-l 127.0.0.1'
sys.argv[2] = '-p taco'
out_buff = StringIO()
sys.stderr = out_buff
try:
server.main()
except SystemExit, ex:
assert ex.message == 2
out_buff.seek(0)
assert 'invalid integer' in out_buff.read()
开发者ID:RHInception,项目名称:talook,代码行数:22,代码来源:test_create_server.py
示例13: main
def main():
fileName = sys.argv[1]
mrm = master.main(fileName)
server.main(mrm, fileName)
client.main(mrm, fileName)
开发者ID:Acidburn0zzz,项目名称:Chainreplication,代码行数:5,代码来源:chainReplication.py
示例14:
#!/usr/bin/env python
# _______ _______ _______ _______ __ __ ___ _______ _______
# | || _ || || || | | || | | || |
# | || |_| ||_ _|| ___|| | | || | | || ___|
# | || | | | | | __ | |_| || | | || |___
# | _|| | | | | || || || | | _|| ___|
# | |_ | _ | | | | |_| || || | | |_ | |___
# |_______||__| |__| |___| |_______||_______||___| |_______||_______|
# --------- A Website For the Purchase of Excellent Things ------------
#
# Coded by Josh Thomas <[email protected]>
# Currated & Owned by Catherine Kern <[email protected]>
#
import server as server
import os, sys
__author__ = "Josh Thomas"
__credits__ = ["Josh Thomas", "Catherine Kern"]
__license__ = "GPL"
__version__ = "0.1"
__maintainer__ = "Josh Thomas"
__contact__ = "http://github.com/lambdanaut"
__email__ = "[email protected]"
__status__ = "Development"
if __name__ == "__main__": server.main()
开发者ID:Catherineee,项目名称:Catguice,代码行数:28,代码来源:main.py
示例15: len
#!/usr/bin/env python
import os
import sys
if len(sys.argv) != (1 + 1):
raise RuntimeError(
'init.py should be ran with one arg DGRAM or SOCK_STREAM'
)
#host = ''
settings = {
'host' : '127.0.0.1',
'port' : 3444,
'mode' : sys.argv[1]
}
if os.fork():
import server
server.main(settings)
else:
import client
client.main(settings)
开发者ID:Nolhian,项目名称:PyUDT,代码行数:24,代码来源:init.py
示例16: execfile
#!/usr/bin/env python
import os
base = os.path.dirname(os.path.abspath(__file__)+'../')
os.environ['PYTHON_EGG_CACHE'] = os.path.join(base, '..', 'misc/virtenv/lib/python2.6/site-packages')
virtualenv = os.path.join(base, '..', 'misc/virtenv/bin/activate_this.py')
execfile(virtualenv, dict(__file__=virtualenv))
sys.path.append(os.path.join(base, "src"))
import server
server.main(os.environ['OPENSHIFT_DIY_IP'])
开发者ID:andretw,项目名称:openshift-tornado-sample,代码行数:11,代码来源:bootstrap.py
示例17: Main
def Main():
friendIP = input("enter your friend's IP:")
senderThread = threading.Thread(target=server.main())
recieverThread = threading.Thread(target=client.main(), args=(friendIP))
senderThread.start()
recieverThread.start()
开发者ID:svolk19,项目名称:tcpChat,代码行数:6,代码来源:tcpChat.py
示例18: test_main
result = conn.sent
if 'HTTP/1.0 200 OK' not in result:
assert False
else:
pass
def test_main():
fakemodule = FakeSocketModule()
sys.argv[1] = '-A'
sys.argv.append('myapp')
success = False
try:
server.main(fakemodule)
except AcceptCalledMultipleTimes:
success = True
pass
assert success, "Something went wrong"
class AcceptCalledMultipleTimes(Exception):
pass
class FakeSocketModule(object):
def getfqdn(self):
return "fakehost"
def socket(self):
return FakeConnection("")
开发者ID:eunbong,项目名称:cse491-serverz,代码行数:31,代码来源:test_server.py
示例19: scan
seed-hosts= with -H, use these hostnames for initial scan (comma-separated)
noserver don't use a separate server process (mostly for debugging)
server [internal use only]
firewall [internal use only]
hostwatch [internal use only]
"""
o = options.Options('sshuttle', optspec)
(opt, flags, extra) = o.parse(sys.argv[1:])
helpers.verbose = opt.verbose
try:
if opt.server:
if len(extra) != 0:
o.fatal('no arguments expected')
sys.exit(server.main())
elif opt.firewall:
if len(extra) != 1:
o.fatal('exactly one argument expected')
sys.exit(firewall.main(int(extra[0])))
elif opt.hostwatch:
sys.exit(hostwatch.hw_main(extra))
else:
if len(extra) < 1 and not opt.auto_nets:
o.fatal('at least one subnet (or -N) expected')
remotename = opt.remote
if remotename == '' or remotename == '-':
remotename = None
if opt.seed_hosts and not opt.auto_hosts:
o.fatal('--seed-hosts only works if you also use -H')
if opt.seed_hosts:
开发者ID:nisc,项目名称:sshuttle,代码行数:31,代码来源:main.py
示例20: cli
def cli():
kwargs = docopt(__doc__)
port = kwargs['<port>']
main(port)
开发者ID:howie6879,项目名称:getNews,代码行数:4,代码来源:myNews.py
注:本文中的server.main函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论