async def leave_room(self, client): if client.uid not in self.server.rooms[client.room]: return self.server.rooms[client.room].remove(client.uid) old_room = self.server.rooms[client.room].copy() if old_room: prefix = common.get_prefix(client.room) online = self.server.online location_name = client.room.split("_")[0] if location_name == "canyon": cc = await get_cc(client.room, self.server) else: cc = None for uid in old_room: try: tmp = online[uid] except KeyError: continue await tmp.send( [f"{prefix}.r.lv", { "uid": client.uid, "cc": cc }]) await tmp.send([client.room, client.uid], type_=17) else: del self.server.rooms[client.room] room = client.room.split("_") if room[0] == "house" and room[1] == client.uid: await self.server.modules["h"].owner_at_house(client.uid, False) client.room = None
async def join_room(self, client, room): if room in self.server.rooms: self.server.rooms[room].append(client.uid) else: self.server.rooms[room] = [client.uid] client.room = room client.position = (-1.0, -1.0) client.action_tag = "" client.state = 0 client.dimension = 4 plr = await gen_plr(client, self.server) prefix = common.get_prefix(client.room) online = self.server.online new_room = self.server.rooms[room].copy() location_name = room.split("_")[0] if location_name == "canyon": client.canyon_lid = "l1" cc = await get_cc(room, self.server) else: cc = None for uid in new_room: if uid not in online: continue tmp = online[uid] await tmp.send([f"{prefix}.r.jn", {"plr": plr, "cc": cc}]) await tmp.send([client.room, client.uid], type_=16)
def get_room(self, msg, client): online = self.server.online.copy() num = 1 while True: i = 0 for tmp in online: if tmp.room == f"{msg[2]['lid']}_{msg[2]['gid']}_{num}": i += 1 if i >= const.ROOM_LIMIT: num += 1 else: break room = f"{msg[2]['lid']}_{msg[2]['gid']}_{num}" if client.room: prefix = common.get_prefix(client.room) for tmp in self.server.online.copy(): if tmp.room != client.room or tmp.uid == client.uid: continue tmp.send([prefix + ".r.lv", {"uid": client.uid}]) tmp.send([client.room, client.uid], type_=17) client.room = room client.position = (-1.0, -1.0) client.action_tag = "" client.state = 0 client.dimension = 4 plr = gen_plr(client, self.server) for tmp in self.server.online.copy(): if tmp.room != client.room: continue tmp.send(["o.r.jn", {"plr": plr}]) tmp.send([client.room, client.uid], type_=16) client.send(["o.gr", {"rid": client.room}])
def execute(args, parser): import sys import json from os.path import isfile from conda.builder.share import clone_bundle common.ensure_name_or_prefix(args, 'clone') prefix = common.get_prefix(args) path = args.path[0] if not isfile(path): sys.exit("Error: no such file: %s" % path) warnings = [] for w in clone_bundle(path, prefix): if args.json: warnings.append(w) else: print "Warning:", w if args.json: json.dump(dict(warnings=warnings), sys.stdout, indent=2)
def refresh_avatar(client, server): plr = gen_plr(client, server) prefix = common.get_prefix(client.room) for tmp in server.online.copy(): if tmp.room != client.room: continue tmp.send([f"{prefix}.r.ra", {"plr": plr}])
def execute(args, parser): import sys from os.path import exists import conda.plan as plan from conda.api import get_index if len(args.package_specs) == 0 and not args.file: sys.exit('Error: too few arguments, must supply command line ' 'package specs or --file') common.ensure_name_or_prefix(args, 'create') prefix = common.get_prefix(args) if exists(prefix): if args.prefix: raise RuntimeError("'%s' already exists, must supply new " "directory for -p/--prefix" % prefix) else: raise RuntimeError("'%s' already exists, must supply new " "directory for -n/--name" % prefix) if args.file: specs = common.specs_from_file(args.file) else: specs = common.specs_from_args(args.package_specs) common.check_specs(prefix, specs) channel_urls = args.channel or () common.ensure_override_channels_requires_channel(args) index = get_index(channel_urls=channel_urls, prepend=not args.override_channels) actions = plan.install_actions(prefix, index, specs) if plan.nothing_to_do(actions): print 'No matching packages could be found, nothing to do' return print print "Package plan for creating environment at %s:" % prefix plan.display_actions(actions, index) common.confirm_yn(args) plan.execute_actions(actions, index, verbose=not args.quiet) if sys.platform != 'win32': activate_name = prefix if args.name: activate_name = args.name print "#" print "# To activate this environment, use:" print "# $ source activate %s" % activate_name print "#" print "# To deactivate this environment, use:" print "# $ source deactivate" print "#"
def execute(args, parser): import conda.plan as plan from conda.api import get_index import pscheck prefix = common.get_prefix(args) # handle explict installs of conda packages if args.packages and all(s.endswith('.tar.bz2') for s in args.packages): from conda.misc import install_local_packages install_local_packages(prefix, args.packages, verbose=not args.quiet) return if any(s.endswith('.tar.bz2') for s in args.packages): raise RuntimeError("cannot mix specifications with conda package " "filenames") if args.force: args.no_deps = True if args.file: specs = common.specs_from_file(args.file) else: specs = common.specs_from_args(args.packages) common.check_specs(prefix, specs) spec_names = set(s.split()[0] for s in specs) if args.no_deps: only_names = spec_names else: only_names = None common.ensure_override_channels_requires_channel(args) channel_urls = args.channel or () index = get_index(channel_urls=channel_urls, prepend=not args.override_channels) actions = plan.install_actions(prefix, index, specs, force=args.force, only_names=only_names) if plan.nothing_to_do(actions): from main_list import list_packages regex = '^(%s)$' % '|'.join(spec_names) print '# All requested packages already installed.' list_packages(prefix, regex) return print print "Package plan for installation in environment %s:" % prefix plan.display_actions(actions, index) if not pscheck.main(args): common.confirm_yn(args) plan.execute_actions(actions, index, verbose=not args.quiet)
def execute(args, parser): import sys import conda.plan as plan import pscheck if not (args.all or args.package_names): sys.exit('Error: no package names supplied,\n' ' try "conda remove -h" for more details') prefix = common.get_prefix(args) index = None if args.features: from conda.api import get_index channel_urls = args.channel or () common.ensure_override_channels_requires_channel(args) index = get_index(channel_urls=channel_urls, prepend=not args.override_channels) features = set(args.package_names) actions = plan.remove_features_actions(prefix, index, features) elif args.all: from conda.install import linked if plan.is_root_prefix(prefix): sys.exit('Error: cannot remove root environment,\n' ' add -n NAME or -p PREFIX option') actions = {plan.PREFIX: prefix, plan.UNLINK: sorted(linked(prefix))} else: specs = common.specs_from_args(args.package_names) no_rm = 'python', 'pycosat', 'conda' if (plan.is_root_prefix(prefix) and common.names_in_specs(no_rm, specs)): sys.exit('Error: cannot remove %s from root environment' % ', '.join(no_rm)) actions = plan.remove_actions(prefix, specs) if plan.nothing_to_do(actions): print 'No packages found to remove from environment: %s' % prefix return print print "Package plan for package removal in environment %s:" % prefix plan.display_actions(actions) if not pscheck.main(args): common.confirm_yn(args) plan.execute_actions(actions, index, verbose=not args.quiet)
def get_room(self, msg, client): room = f"{msg[2]['lid']}_{msg[2]['gid']}_{msg[2]['rid']}" if client.room: prefix = common.get_prefix(client.room) for tmp in self.server.online.copy(): if tmp.room != client.room or tmp.uid == client.uid: continue tmp.send([f"{prefix}.r.lv", {"uid": client.uid}]) tmp.send([client.room, client.uid], type_=17) client.room = room client.position = (-1.0, -1.0) client.action_tag = "" client.state = 0 client.dimension = 4 plr = gen_plr(client, self.server) for tmp in self.server.online.copy(): if tmp.room != client.room: continue prefix = common.get_prefix(client.room) tmp.send([f"{prefix}.r.jn", {"plr": plr}]) tmp.send([client.room, client.uid], type_=16) client.send(["h.gr", {"rid": client.room}])
async def refresh_avatar(client, server): if not client.room: return plr = await gen_plr(client, server) prefix = common.get_prefix(client.room) online = server.online room = server.rooms[client.room].copy() for uid in room: try: tmp = online[uid] except KeyError: continue await tmp.send([f"{prefix}.r.ra", {"plr": plr}])
def _close_connection(self): self.connection.close() logging.debug(f"Connection closed with {self.address[0]}") if self.uid: if self.room: prefix = common.get_prefix(self.room) for client in self.server.online.copy(): if client.room != self.room: continue client.send([prefix+".r.lv", {"uid": self.uid}]) client.send([self.room, self.uid], type_=17) if self.uid in self.server.inv: self.server.inv[self.uid].expire = time.time()+30 self.server.online.remove(self) del self
def execute(args, parser): import sys import json from conda.builder.share import create_bundle prefix = common.get_prefix(args) path, warnings = create_bundle(prefix) if args.json: d = dict(path=path, warnings=warnings) json.dump(d, sys.stdout, indent=2, sort_keys=True) else: for w in warnings: print "Warning:", w print path
def execute(args, parser): import re import conda.install as install from conda.api import get_index from conda.resolve import MatchSpec, Resolve if args.regex: pat = re.compile(args.regex, re.I) else: pat = None prefix = common.get_prefix(args) if not args.canonical: linked = install.linked(prefix) common.ensure_override_channels_requires_channel(args, dashc=False) channel_urls = args.channel or () index = get_index(channel_urls=channel_urls, prepend=not args.override_channels) r = Resolve(index) for name in sorted(r.groups): disp_name = name if pat and pat.search(name) is None: continue for pkg in sorted(r.get_pkgs(MatchSpec(name))): dist = pkg.fn[:-8] if args.canonical: print dist continue inst = '*' if dist in linked else ' ' print '%-25s %s %-15s %15s %s' % ( disp_name, inst, pkg.version, r.index[pkg.fn]['build'], common.disp_features(r.features(pkg.fn))) disp_name = ''
def get_room(self, msg, client): if "rid" not in msg[2]: num = 1 room = f"{msg[2]['lid']}_{msg[2]['gid']}_{num}" while True: if self._get_room_len(room) >= const.ROOM_LIMIT: num += 1 else: break else: room = f"{msg[2]['lid']}_{msg[2]['gid']}_{msg[2]['rid']}" if msg[2]["gid"][-1] == "e": limit = const.EVENT_ROOM_LIMIT else: limit = const.ROOM_LIMIT if self._get_room_len(room) >= limit: return if client.room: prefix = common.get_prefix(client.room) for tmp in self.server.online.copy(): if tmp.room != client.room or tmp.uid == client.uid: continue tmp.send([prefix + ".r.lv", {"uid": client.uid}]) tmp.send([client.room, client.uid], type_=17) client.room = room client.position = (-1.0, -1.0) client.action_tag = "" client.state = 0 client.dimension = 4 plr = gen_plr(client, self.server) for tmp in self.server.online.copy(): if tmp.room != client.room: continue tmp.send(["o.r.jn", {"plr": plr}]) tmp.send([client.room, client.uid], type_=16) client.send(["o.gr", {"rid": client.room}])
def execute(args, parser): from os.path import basename from conda.builder.packup import make_tarbz2, untracked, remove prefix = common.get_prefix(args) if args.check: from conda.builder.tarcheck import check_all try: check_all(args.check) print '%s OK' % basename(args.check) except Exception as e: print e print '%s FAILED' % basename(args.check) return print '# prefix:', prefix if args.reset: remove(prefix, untracked(prefix)) return if args.untracked: files = sorted(untracked(prefix)) print '# untracked files: %d' % len(files) for fn in files: print fn return make_tarbz2(prefix, name = args.pkg_name, version = args.pkg_version, build_number = int(args.pkg_build))
#!/usr/bin/env python3 from kafka import KafkaProducer, KafkaConsumer from kafka.errors import KafkaError from common import get_prefix, get_brokers import boto3 import json import time # Build up a mapping of Kafka Topic Name => Kinesis Stream Name prefix = get_prefix() if prefix is None: raise Exception("Unable to find prefix?") topic_to_stream = { "customers": "{prefix}-customer-stream".format(prefix=prefix), } # Build a list of Kafka Consumers => Kinesis Stream Names brokers = get_brokers() consumers = [] for topic_name, stream_name in topic_to_stream.items(): consumer = KafkaConsumer( topic_name, bootstrap_servers=brokers, value_deserializer=lambda m: json.loads(m.decode("utf-8")), auto_offset_reset="earliest",
def execute(args, parser): prefix = common.get_prefix(args) list_packages(prefix, args.regex, not args.canonical)