def handle(self, *args, **options): username = options["username"] if username: user = User.objects.get(username=username) else: user = None for file in options["file"]: print("Uploading %r" % (file)) metadata = { "build": 0, "match_start": now().isoformat(), } event = UploadEvent( upload_ip="127.0.0.1", metadata=json.dumps(metadata), ) event.file = file event.save() with open(file, "r") as f: event.file = File(f) event.save() event.process() self.stdout.write("%r: %s" % (event, event.get_absolute_url())) if event.game: event.game.user = user event.game.save() self.stdout.write("%r: %s" % (event.game, event.game.get_absolute_url())) self.stdout.write("Replay: %s" % (event.game.replay_xml.url))
def handle(self, *args, **options): if options["force_attach"]: user = User.objects.get(username=options["force_attach"]) if not user: raise CommandError( f"User {repr(options['force_attach'])} not found") else: user = None if options["pick_token"]: user = User.objects.get(username=options["pick_token"]) if not user: raise CommandError( f"User {repr(options['pick_token'])} not found") token = user.auth_tokens.first() else: token = None for file in options["file"]: self.stdout.write(f"Uploading {repr(file)}") metadata = { "build": 0, "match_start": now().isoformat(), "game_type": enums.BnetGameType.BGT_RANKED_STANDARD, "format": enums.FormatType.FT_STANDARD, } event = UploadEvent( upload_ip="127.0.0.1", metadata=json.dumps(metadata), token_uuid=token.key if token else None, ) event.file = file event.save() with open(file, "r") as f: event.file = File(f) event.save() event.process() self.stdout.write("%r: %s" % (event, event.get_absolute_url())) if event.game: if user: # only overwrite user if forced (via --username) event.game.user = user event.game.save() self.stdout.write("%r: %s" % (event.game, event.game.get_absolute_url())) self.stdout.write("Replay: %s" % (event.game.replay_xml.url))
def handle(self, *args, **options): for file in options["file"]: print("Uploading %r" % (file)) metadata = { "build": 0, "match_start": now().isoformat(), } event = UploadEvent( type=UploadEventType.POWER_LOG, upload_ip="127.0.0.1", metadata=json.dumps(metadata), ) event.file = file event.save() with open(file, "r") as f: event.file = File(f) event.save() event.process() self.stdout.write("%r: %s" % (event, event.get_absolute_url()))
def handle(self, *args, **options): if options["force_attach"]: user = User.objects.get(username=options["force_attach"]) if not user: raise CommandError(f"User {repr(options['force_attach'])} not found") else: user = None for file in options["file"]: self.stdout.write(f"Uploading {repr(file)}") metadata = { "build": 0, "match_start": now().isoformat(), } event = UploadEvent( upload_ip="127.0.0.1", metadata=json.dumps(metadata), ) event.file = file event.save() with open(file, "r") as f: event.file = File(f) event.save() event.process() self.stdout.write("%r: %s" % (event, event.get_absolute_url())) if event.game: if user: # only overwrite user if forced (via --username) event.game.user = user event.game.save() self.stdout.write("%r: %s" % (event.game, event.game.get_absolute_url())) self.stdout.write("Replay: %s" % (event.game.replay_xml.url))
def handle(self, *args, **options): username = options["username"] username_to_pick_from = options["pick_token"] raw_token = options["token"] if username: user = User.objects.get(username=username) if not user: raise Exception("User not found") self.stdout.write(" ".join(( "Warning: Will only attach to user after processing and not fire webhooks.", "Use --pick-token instead.", ))) token = None elif username_to_pick_from: user = User.objects.get(username=username_to_pick_from) # pick the user's first token token = user.auth_tokens.first() if token: self.stdout.write( "Picked auth token %s (owned by %s)" % (token, token.user) ) else: raise Exception("No auth token found") # should already be attached by token user = None elif raw_token: user = None token = AuthToken.objects.get(key=raw_token) if not token: raise Exception("Auth token not found") else: user = None token = None for file in options["file"]: print("Uploading %r" % (file)) metadata = { "build": 0, "match_start": now().isoformat(), } event = UploadEvent( upload_ip="127.0.0.1", metadata=json.dumps(metadata), token=token, ) event.file = file event.save() with open(file, "r") as f: event.file = File(f) event.save() event.process() self.stdout.write("%r: %s" % (event, event.get_absolute_url())) if event.game: if user: # only overwrite user if forced (via --username) event.game.user = user event.game.save() self.stdout.write("%r: %s" % (event.game, event.game.get_absolute_url())) self.stdout.write("Replay: %s" % (event.game.replay_xml.url))