def getod(): print('getod is running') name = gethostname() UDP_sock = socket(AF_INET, SOCK_DGRAM) address1 = gethostbyname(name) print(address1) UDP_sock.bind((address1, 8080)) while True: sleep(1) ODrawvalue_ascll = UDP_sock.recvfrom(10000) ODrawvalue_ascll = ODrawvalue_ascll[0][2:5].decode('utf-8') times = 2 sums = [] for items in ODrawvalue_ascll: if items.isdecimal(): number = ord(items) - 48 number = number * 16**times sums.append(number) else: number = ord(items) - 87 number = number * 16**times sums.append(number) times -= 1 # sleep(1) result_list.append(sum(sums)) del (ODrawvalue_ascll)
def gethostbyname(hostname): """:func:`socket.gethostbyname` implemented using :mod:`gevent.dns`. Differs in the following ways: * raises :class:`DNSError` (a subclass of :class:`socket.gaierror`) with dns error codes instead of standard socket error codes * does not support ``/etc/hosts`` but calls the original :func:`socket.gethostbyname` if *hostname* has no dots * does not iterate through all addresses, instead picks a random one each time """ # TODO: this is supposed to iterate through all the addresses # could use a global dict(hostname, iter) # - fix these nasty hacks for localhost, ips, etc. if not isinstance(hostname, str) or '.' not in hostname: return _socket.gethostbyname(hostname) if _ip4_re.match(hostname): return hostname if hostname == _socket.gethostname(): return _socket.gethostbyname(hostname) addrs = None try: _ttl, addrs = resolve_ipv4(hostname) except: _ttl, addrs = resolve_ipv6(hostname) return inet_ntop(AF_INET6, random.choice(addrs)) else: return inet_ntop(AF_INET, random.choice(addrs))
def authenticate_interactive(app_name=None, bridge_host=None, client_name=None, force=False): if not force: # Don't reauthenticate if we already have the username on disk existing_username = load_username() if existing_username: return existing_username host_name = gethostname() bridge_host = raw_input("Philips Hue Bridge IP address or " "host name [philips-hue]: " ).strip() or 'philips-hue' app_name = raw_input("Your application name [test-app]").strip() or 'test-app' client_name = raw_input("Your device name [{}]" .format(host_name)).strip() or host_name username = None while not username: raw_input('Now press the link button on the Hue Bridge. Press enter when done.') try: username = authenticate( bridge_host=bridge_host, app_name=app_name, client_name=client_name) except exceptions.LinkButtonNotPressed: print 'Error, link button not pressed, trying again...' print 'Your username is: {}'.format(username) if raw_input('Save username to {} [Y/n]?'.format(USERNAME_SAVE_PATH)) != 'n': save_username(username)
def make_message(s, **kwargs): # noinspection PyBroadException try: user = getpass.getuser() except Exception: # noinspection PyBroadException try: import os user = '******'.format(os.getuid()) except Exception: user = '******' # noinspection PyBroadException try: host = gethostname() except Exception: host = 'localhost' args = dict( user=user, host=host, time=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') ) args.update(kwargs) return s % args
def authenticate(app_name, bridge_host, client_name=None): client_name = client_name or gethostname() url = 'http://{}/api'.format(bridge_host) response = requests.post(url, json={ 'devicetype': '{}#{}'.format(app_name, client_name), }) json = parse_response(response) return json[0]['success']['username']
def make_message(s, **kwargs): args = dict( user=getpass.getuser(), host=gethostname(), time=datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S') ) args.update(kwargs) return s % args
def testHostName(): smthing = socket.getaddrinfo("joshua.it.uu.se",6969) smthing = smthing[0] smthing = smthing[4:]#[0] print("getaddrinfo return: {}".format(smthing) ) myLocalHost = gethostname() print (myLocalHost) myIP = gethostbyname(myLocalHost) print(myIP)
def producer(*args, **kwargs): """ Run a producer process. """ kwargs['queues'] = kwargs.get('queues') or ['producer'] kwargs['hostname'] = kwargs.get('hostname') or 'producer@{}'.format( gethostname()) worker = app.Worker(**kwargs) worker.start() return worker.exitcode
def store_debug_info(): setup, pydev = get_pydev_debug_setup() data = {"pydev": pydev, "setup": setup, "debug_host": gethostname()} from firexapp.engine.celery import app logs_dir = app.backend.get('logs_dir').decode() json_path = FileRegistry().get_file(PYDEV_REGISTRY_KEY, logs_dir) print("Storing debugging information", file=sys.stdout) with open(json_path, 'w') as outfile: json.dump(data, outfile)
def conn_system(self): s = socket() s.connect((gethostname(), 12345)) s.sendall("REGME " + str(SERVER_HOST) + ":" + str(SERVER_PORT)) ans = s.recv(100) if ans.strip() == "REGWA": time.sleep(3) s.sendall("REGME " + str(SERVER_HOST) + ":" + str(SERVER_PORT)) ans = s.recv(100) if ans.strip() == "REGOK": return True else: return False
def create_mhl(start: datetime): start = start.replace(microsecond=0).isoformat() + "Z" finish = datetime.datetime.utcnow().replace(microsecond=0).isoformat() + "Z" new_mhl = E.hashlist( E.creatorinfo( E.name(get_user_display_name()), E.username(getpass.getuser()), E.hostname(gethostname()), E.tool("o/COPY"), E.startdate(start), E.finishdate(finish), ), version="1.1", ) return new_mhl
def bindSocket(s, BindPort, local_ip): try: s.bind(('', BindPort)) get_date_string() if local_ip != '': print("server: + $local_ip + $BindPort") else: print("server:" + str(gethostbyname(gethostname())) + str(BindPort)) except Exception as e: print(e) get_date_string() print("ERROR: nie mozna zabindowac portu %s, wybierz inny BindPort") s.close() sys.exit()
def get_pydev_command(cmd, setup=None, pydev=None, debug_host=None): if not setup: setup, pydev = get_pydev_debug_setup() pydev_cmd = [sys.executable, pydev] client = str(setup['client']) client = client if "127.0.0.1" not in client else (debug_host or gethostname()) pydev_cmd += [ '--multiproc', '--client', client, '--port', str(setup['port']), '--file' ] if type(cmd) is str: cmd = [cmd] pydev_cmd += cmd return pydev_cmd
def setup_notifier(self): parser = self._get_parser() port = 8100 elem = parser.get_elements('port') if elem is not None: try: port = int(elem[0].text.strip()) except ValueError: pass self.notifier.port = port host = gethostbyname(gethostname()) self.url = '{}:{}'.format(host, port) #add a config request handler self.notifier.add_request_handler('config', self._handle_config)
def setup_notifier(self): parser = self._get_parser() port = 8100 elem = parser.get_elements("port") if elem is not None: try: port = int(elem[0].text.strip()) except ValueError: pass self.notifier.port = port host = gethostbyname(gethostname()) self.url = "{}:{}".format(host, port) # add a config request handler self.notifier.add_request_handler("config", self._handle_config)
def authenticate(self, app_name, bridge_host, client_name=None): client_name = client_name or gethostname() url = 'http://{}/api'.format(bridge_host) response = requests.post(url, json={ 'devicetype': '{}#{}'.format(app_name, client_name), }) data = response.json() #json = parse_response(response) print('response:') print(data[0]) if 'error' in data[0].keys(): print('ERROR') print('ERROR:', data[0]['error']['description']) else: print('NO ERROR') self.save_creds(data[0]['success']['username'], bridge_host)
def listen(self, **kwargs): """ Register the Application to a port/address """ # xheaders in settings? kwargs['xheaders'] = kwargs.get('xheaders', self.settings.get('xheaders', False)) # Check for host setting if not self.host: realaddress = urljoin('http://%s:%s' % (gethostname().split(".")[0], self.port), '.') super().listen(port=self.port, **kwargs) else: realaddress = urljoin('http://%s:%s' % (self.host, self.port), '.') super().listen(port=self.port, address=self.host, **kwargs) # Return connected interface return realaddress
def authenticate_interactive(app_name=None, bridge_host=None, client_name=None, force=False): if not force: # Don't reauthenticate if we already have the username on disk existing_username = load_username() if existing_username: return existing_username host_name = gethostname() bridge_host = raw_input( "Philips Hue Bridge IP address or " "host name [philips-hue]: ").strip() or 'philips-hue' app_name = raw_input( "Your application name [test-app]").strip() or 'test-app' client_name = raw_input( "Your device name [{}]".format(host_name)).strip() or host_name username = None while not username: raw_input( 'Now press the link button on the Hue Bridge. Press enter when done.' ) try: username = authenticate(bridge_host=bridge_host, app_name=app_name, client_name=client_name) except exceptions.LinkButtonNotPressed: print 'Error, link button not pressed, trying again...' print 'Your username is: {}'.format(username) if raw_input( 'Save username to {} [Y/n]?'.format(USERNAME_SAVE_PATH)) != 'n': save_username(username)
def url(self): host = gethostbyname(gethostname()) return '{}:{}'.format(host, self.port)
logging.basicConfig(level = logging.INFO) consumer_logger = logging.getLogger('consumer') if len(sys.argv) < 2: consumer_logger.error('python consumer.py http_port') sys.exit(-1) # 1, 将自己的HTTP监听地址注册到ZK上 http_port = sys.argv[1] zkclient = KazooClient('localhost:3000,localhost:3001,localhost:3002/kafka') zkclient.start() zk_path = '/consumers/balance-consumer/nodes/' + gethostname() + ":" + str(sys.argv[1]) registed = False for times in range(0, 5): try: try: node_dir = zkclient.get('/consumers/balance-consumer/nodes') # 目录不存在 except: zkclient.create('/consumers/balance-consumer/nodes') # 创建目录 registed = zkclient.create(zk_path, ephemeral = True) consumer_logger.info('register to zookeeper, path={}'.format(zk_path)) break except: consumer_logger.warning('fail to register to zookeeper[{}], retry 5 seconds later...'.format(zk_path)) sleep(5)
Line 9: NBC Contamination Further ideas; Dial up internet- track the ip address to find the geo location """ import datetime import _socket # s = socket.socket(socket.AF_INET, socket.sock_DGRAM) # s.connect("8.8.8.8",80) IP = _socket.gethostbyname(_socket.gethostname()) class medivac(): def __init__(self): self.date= datetime.datetime.now() self.ip_address =IP def __repr__(self): raise NotImplementedError class ninelines(medivac): """ This initializes the 9 lines of medivac :param line_1: Location of the pick-up site. :param line_2: Radio frequency, call sign, and suffix.
def curr_proc_host() -> str: return str(os.getpid()) + "@" + gethostname()
official_name, aliases, addresses = _socket.gethostbyname_ex(name) except _socket.error, ex: raise AddressError(*ex.args) aliases.append(official_name) aliases.append(name) return cls(official_name, addresses[0], aliases, addresses) def resolve(name_or_addr): """ resolves the given host name or host address to a Resolver instance. this function uses a heuristic to 'guess' the format of name_or_addr: if it's a valid ip string, it is resolved by address; otherwise it is resolved by name. if you need to be explicit, use Address.from_addr or Address.from_name instead. """ try: canonize_ipaddr(name_or_addr) except ValueError: return Address.from_name(name_or_addr) else: return Address.from_addr(name_or_addr) # # built-in addresses # loopback = Address.from_addr("127.0.0.1") thishost = Address.from_name(_socket.gethostname()) anyhost = Address.from_addr("0.0.0.0")
import threading from Queue import Queue from _socket import gethostname from socket import socket import time THREADNUM = 5 CONNECT_POINT_LIST = [] # list array of [ip,port,type,time] SERVER_PORT = 12345 SERVER_HOST = gethostname() class ServerThread(threading.Thread): def __init__(self, name, server_conn_queue): super(ServerThread, self).__init__() self.name = name self.conn = None self.conn_addr = None self.queue = server_conn_queue self.threads = [] self.host = SERVER_HOST self.server_socket = socket() self.port = SERVER_PORT def run(self): self.server_socket.bind((self.host, self.port)) self.server_socket.listen(10) while True: try:
def record_factory(*args, **kwargs): record = old_factory(*args, **kwargs) record.hostname = gethostname() return record
from _socket import gethostname #if you are running both server and client on same computer then don't change anything hostname=gethostname() #'server IPaddress here' #if you have different computers for server and client then make sure that both computer must connect to same network # comment the above value of hostname and find out the ipaddress of the server by typing 'ipconfig' in cmd of the server #the look out for ipaddress and change the value of hostname from gethostname() to server ipaddress and put it in single quotes
def post_query_view(request): advertisement_images_list = [] verticle_ads_list = [] advertisement_images = AdvertisementDetails.objects.all() for a in advertisement_images: ads_image = str(a.Ads_images) if a.ads_category == 'Bottom Image Banner': advertisement_images_list.append(ads_image) else: verticle_ads_list.append(ads_image) all_menu_category = Menu_Category.objects.all() all_sub_category = Sub_Category.objects.all() all_region = Region.objects.all() form = CaptchaForm() menu_category_details = Menu_Category.objects.filter(menu_category="Arbeit") for m in menu_category_details: menu_id = m.id sub_category_details = Sub_Category.objects.filter(menu_category_id = menu_id) if request.POST: menu_category = request.POST.get('menu_category').encode('utf-8') sub_category = request.POST.get('sub_category') select_region = request.POST.get('region').encode('utf-8') if request.POST.get('title'): title = request.POST.get('title').encode('utf-8') if request.POST.get('description'): description = request.POST.get('description').encode('utf-8') agree = request.POST.get('agree') if agree == "on": contact = request.POST.get('contact').encode('utf-8') name = request.POST.get('name').encode('utf-8') tel_no = request.POST.get('tel').encode('utf-8') company_name = request.POST.get('company_name').encode('utf-8') set_timer = request.POST.get('set_timer').encode('utf-8') post_time = datetime.datetime.now() try: post_image = request.FILES['post_images'].encode('utf-8') except MultiValueDictKeyError: post_image = False challenge_field = request.POST['recaptcha_challenge_field'] if request.POST['recaptcha_response_field']: response_field = request.POST['recaptcha_response_field'] client_ip_address = gethostbyname(gethostname()) d = confirm(client_ip_address, recaptcha_challenge_field=challenge_field, recaptcha_response_field=response_field) if d: add_post_details_object = Add_Post_Details.objects.create(menu_category=menu_category,sub_category=sub_category,title=title,description=description,\ contact=contact,name=name, tel=tel_no,company_name=company_name, set_timer= set_timer, post_time=post_time, region=select_region) add_post_details_object.save() try: if request.POST.get("nof_image_field"): nof_image_field = int(request.POST.get("nof_image_field")) for i in range(nof_image_field): post_image = request.FILES[str(i+1)] Post_Images.objects.create(post=add_post_details_object,post_image=post_image) else: post_image = request.FILES["1"] Post_Images.objects.create(post=add_post_details_object,post_image=post_image) except MultiValueDictKeyError: post_image = False else: error = "Captcha not match!" return render(request, 'post-query.html', {'form':form,'error': error, 'selected_data':request.POST,'all_menu_category':all_menu_category,'all_sub_category':all_sub_category, 'all_region':all_region,'menu_category':'Arbeit','sub_category_details':sub_category_details,'ads_image':advertisement_images_list,'verticle_ads_list':verticle_ads_list}) else: error = "Plz Enter Captcha!" return render(request, 'post-query.html', {'form':form,'error': error, 'selected_data':request.POST,'all_menu_category':all_menu_category,'all_sub_category':all_sub_category, 'all_region':all_region,'menu_category':'Arbeit','sub_category_details':sub_category_details,'ads_image':advertisement_images_list,'verticle_ads_list':verticle_ads_list}) else: error = "Plz agree to our Terms & condition and Privacy Policy!" return render(request, 'post-query.html', {'form':form,'error': error, 'selected_data':request.POST,'all_menu_category':all_menu_category,'all_sub_category':all_sub_category, 'all_region':all_region,'menu_category':'Arbeit','sub_category_details':sub_category_details,'ads_image':advertisement_images_list,'verticle_ads_list':verticle_ads_list}) else: error = "Plz Enter Description!" return render(request, 'post-query.html', {'form':form,'error': error, 'selected_data':request.POST,'all_menu_category':all_menu_category,'all_sub_category':all_sub_category, 'all_region':all_region,'menu_category':'Arbeit','sub_category_details':sub_category_details,'ads_image':advertisement_images_list,'verticle_ads_list':verticle_ads_list}) else: error = "Plz Enter Title Name!" return render(request, 'post-query.html', {'form':form,'error': error, 'selected_data':request.POST,'all_menu_category':all_menu_category,'all_sub_category':all_sub_category, 'all_region':all_region,'menu_category':'Arbeit','sub_category_details':sub_category_details,'ads_image':advertisement_images_list,'verticle_ads_list':verticle_ads_list}) return HttpResponseRedirect('/index/') else: return render(request, 'post-query.html', {'form':form,'all_menu_category':all_menu_category,'all_sub_category':all_sub_category,'all_region':all_region, 'sub_category_details':sub_category_details,'ads_image':advertisement_images_list,'verticle_ads_list':verticle_ads_list})
#!/usr/bin/env python import _socket import threading print (_socket.gethostname()," ") def func(): sock=_socket.socket(_socket.AF_INET,_socket.SOCK_STREAM) server_address=('localhost',9527) sock.connect(server_address) while True: message="select * from weathers where city_name='西安'" sock.sendall(message.encode()) data=sock.recv(2048) if not data : break else : print (data.decode()) sock.close() if __name__=='__main__': jobs=[] for i in range(5): t=threading.Thread(target=func) jobs.append(t) t.start() for j in jobs: j.join()
# SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = env( 'SECRET_KEY', str, ''.join([ SystemRandom().choice('abcdefghijklmnopqrstuvwxyz0123456789') for i in range(50) ]), ) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = True ALLOWED_HOSTS = tuple( env('ALLOWED_HOSTS', list, ['localhost', '127.0.0.1', gethostname(), '*'])) # For now, allow CORS requests from all domains. TODO - Change this. CORS_ORIGIN_ALLOW_ALL = True # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'quiz.apps.QuizConfig', 'oauth2_provider',
@app.route('/yeahboy') def yeahboy(): return render_template('mis/yeahboy.html') @app.route('/nsp') def nsp(): return render_template('mis/nspHistory.html') @app.route('/HeLives') def helives(): return render_template('mis/heLives.html') @app.route('/sixth') def sixthfprm(): return render_template('sixthForm.html') @app.route('/sweden') def sweden(): return render_template('sweden.html') return app create_app() # Start development web server if __name__ == '__main__': if 'liveconsole' not in gethostname(): app.run()
import _socket as socket import struct import sys import re HOST = socket.gethostbyname(socket.gethostname()) PORT = 0 class TCPSniffer: def __init__(self): self.s = self.connect() def __enter__(self): return self def __exit__(self, exc_type, exc_val, exc_tb): self.s.ioctl(socket.SIO_RCVALL, socket.RCVALL_OFF) def connect(self): s = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_IP) s.bind((HOST, 0)) s.setsockopt(socket.IPPROTO_IP, socket.IP_HDRINCL, 1) s.ioctl(socket.SIO_RCVALL, socket.RCVALL_ON) return s def receive_data(self): try:
# Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.0/howto/deployment/checklist/ SECRET_KEY = "6e2bmahu38vuzy0fd2xw*jz32*9tva_lp=$c!^v6pu)-4qd4k7" EXPOSED_DOMAIN = f'@= project_name =@.{os.getenv("ENVIRONMENT_DOMAIN", "")}' ALLOWED_HOSTS = [ "localhost", "127.0.0.1", "@= project_name =@", "@= project_name [email protected]", gethostname(), gethostbyname(gethostname()), EXPOSED_DOMAIN, ] # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', "commands", "django_prometheus",
except _socket.error, ex: raise AddressError(*ex.args) aliases.append(official_name) aliases.append(name) return cls(official_name, addresses[0], aliases, addresses) def resolve(name_or_addr): """ resolves the given host name or host address to a Resolver instance. this function uses a heuristic to 'guess' the format of name_or_addr: if it's a valid ip string, it is resolved by address; otherwise it is resolved by name. if you need to be explicit, use Address.from_addr or Address.from_name instead. """ try: canonize_ipaddr(name_or_addr) except ValueError: return Address.from_name(name_or_addr) else: return Address.from_addr(name_or_addr) # # built-in addresses # loopback = Address.from_addr("127.0.0.1") thishost = Address.from_name(_socket.gethostname()) anyhost = Address.from_addr("0.0.0.0")
def format(self, domain, level, message): """Override to not log traceback""" date = strftime('%Y-%m-%d %H:%M:%S') host = gethostname() header = '{0} {1}: {2}\n' return header.format(date, host, message)
import threading from Queue import Queue from _socket import gethostname from random import randint from socket import socket, error import ip import time THREADNUM = 3 CONNECT_POINT_LIST = [[gethostname(), 12345, "N", time.time()]] # list array of [ip,port,type,time] # initialised with known nego FUNCTION_LIST = ["grayscale", "binarize:threshold", "sobelfilter:threshold", "prewittfilter:threshold"] SERVER_HOST = gethostname() SERVER_PORT = randint(50000, 65000) class ServerWorkerThread(threading.Thread): def __init__(self, name, inqueue, cpl_lock, client_queue): super(ServerWorkerThread, self).__init__(name=name) self.client_queue = client_queue self.cpl_lock = cpl_lock self.inqueue = inqueue self.connection = None def parser(self, request): request = request.strip() if len(request) >= 5: if request[0:5] == "HELLO": # hello request doesn't need registration. data = "SALUT P" self.connection[0].sendall(data) elif not request[0:5] == "REGME": # if the protocol is not register, check the cpl
def main_context(): """ Include some basic assets in the startup page """ today = datetime.today() current_ip = gethostbyname(gethostname()) return locals()
portmap_success, upnp = (None, None) if not portmap_success: log("Couldn't forward port at the gateway.", "warning") log("Internet hosts will not be able to initiate connections to us.", "warning") try: app.routes = dht.Routers() sys.exitfunc = app.routes.leave_networks if portmap_success and options.address == '0.0.0.0': addr = upnp.externalipaddress() elif options and options.address != '0.0.0.0': addr = options.address else: addr = _socket.gethostbyname(_socket.gethostname()) # Get on the default network router = dht.RoutingTable( addr, options.port, app.key.publickey().exportKey(), httpd, nodes=app.bootstrap_nodes, network=app.default_network, autoreplicate=options.autoreplicate ) app.routes.append(router) # Reload prior networks for network in Network.query.all():
import socket from _socket import gethostname from threading import Thread from threading import Timer import time import sys #constants SERVER_IP = "10.0.0.1" SERVER_PORT = 7777 #SERVER_IP = "127.0.0.1" #SERVER_PORT = int (sys.argv[1]) HOST_NAME = gethostname() TIMER_IDLE_PEER = 1 MAX_IDLE_TIME = 10 #variables peer_list = [[]] found_peers = [[]] # Timer Function for removing idle peers def timer_function(): for i in range(len(peer_list)-1): len_lst = len(peer_list[i+1]) cur_time = time.time() previous_time = float(peer_list[i+1][len_lst-1]) if (cur_time - previous_time) > MAX_IDLE_TIME: peer_list.pop(i+1) print peer_list
logging.basicConfig(level=logging.INFO) consumer_logger = logging.getLogger('consumer') if len(sys.argv) < 2: consumer_logger.error('python consumer.py http_port') sys.exit(-1) # 1, 将自己的HTTP监听地址注册到ZK上 http_port = sys.argv[1] zkclient = KazooClient('localhost:3000,localhost:3001,localhost:3002/kafka') zkclient.start() zk_path = '/consumers/balance-consumer/nodes/' + gethostname() + ":" + str( sys.argv[1]) registed = False for times in range(0, 5): try: try: node_dir = zkclient.get( '/consumers/balance-consumer/nodes') # 目录不存在 except: zkclient.create('/consumers/balance-consumer/nodes') # 创建目录 registed = zkclient.create(zk_path, ephemeral=True) consumer_logger.info('register to zookeeper, path={}'.format(zk_path)) break except: consumer_logger.warning(