bugged
stringlengths
4
228k
fixed
stringlengths
0
96.3M
__index_level_0__
int64
0
481k
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
449,500
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
449,501
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
449,502
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
def fake_response(job, winner): result = Game_result({'b' : 't1', 'w' : 't2'}, winner) response = Game_job_result() response.game_id = job.game_id response.game_result = result response.engine_names = {} response.engine_descriptions = {} response.game_data = job.game_data return response
449,503
def _make_proxy(): channel = gtp_engine_fixtures.get_test_channel() controller = gtp_controller.Gtp_controller(channel, 'testbackend') proxy = gtp_proxy.Gtp_proxy() proxy.set_back_end_controller(controller) # Make the commands from the underlying Recording_gtp_engine_protocol # available to tests proxy._commands_handle...
def _make_proxy(): channel = gtp_engine_fixtures.get_test_channel() controller = gtp_controller.Gtp_controller(channel, 'testbackend') proxy = gtp_proxy.Gtp_proxy() proxy.set_back_end_controller(controller) # Make the commands from the underlying Recording_gtp_engine_protocol # available to tests proxy._commands_handle...
449,504
def test_proxy(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'test', ['ab', 'cd'], "args: ab cd") proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('test', ['ab', 'cd']), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
def test_proxy(tc): fx = Proxy_fixture(tc) fx.check_command('test', ['ab', 'cd'], "args: ab cd") fx.proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('test', ['ab', 'cd']), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
449,505
def test_proxy(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'test', ['ab', 'cd'], "args: ab cd") proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('test', ['ab', 'cd']), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
def test_proxy(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'test', ['ab', 'cd'], "args: ab cd") proxy.close() tc.assertEqual( fx.commands_handled, [('list_commands', []), ('test', ['ab', 'cd']), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
449,506
def test_proxy(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'test', ['ab', 'cd'], "args: ab cd") proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('test', ['ab', 'cd']), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
def test_proxy(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'test', ['ab', 'cd'], "args: ab cd") proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('test', ['ab', 'cd']), ('quit', [])]) tc.assertTrue(fx.controller.channel.is_closed)
449,507
def test_close_after_quit(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'quit', [], "", expect_end=True) proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
def test_close_after_quit(tc): fx = Proxy_fixture(tc) fx.check_command('quit', [], "", expect_end=True) fx.proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
449,508
def test_close_after_quit(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'quit', [], "", expect_end=True) proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
def test_close_after_quit(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'quit', [], "", expect_end=True) proxy.close() tc.assertEqual( fx.commands_handled, [('list_commands', []), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
449,509
def test_close_after_quit(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'quit', [], "", expect_end=True) proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('quit', [])]) tc.assertTrue(proxy.controller.channel.is_closed)
def test_close_after_quit(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'quit', [], "", expect_end=True) proxy.close() tc.assertEqual( proxy._commands_handled, [('list_commands', []), ('quit', [])]) tc.assertTrue(fx.channel.is_closed)
449,510
def test_list_commands(tc): proxy = _make_proxy() tc.assertListEqual( proxy.engine.list_commands(), ['error', 'fatal', 'gomill-passthrough', 'known_command', 'list_commands', 'multiline', 'protocol_version', 'quit', 'test']) proxy.close()
def test_list_commands(tc): fx = Proxy_fixture(tc) tc.assertListEqual( proxy.engine.list_commands(), ['error', 'fatal', 'gomill-passthrough', 'known_command', 'list_commands', 'multiline', 'protocol_version', 'quit', 'test']) proxy.close()
449,511
def test_list_commands(tc): proxy = _make_proxy() tc.assertListEqual( proxy.engine.list_commands(), ['error', 'fatal', 'gomill-passthrough', 'known_command', 'list_commands', 'multiline', 'protocol_version', 'quit', 'test']) proxy.close()
def test_list_commands(tc): proxy = _make_proxy() tc.assertListEqual( fx.engine.list_commands(), ['error', 'fatal', 'gomill-passthrough', 'known_command', 'list_commands', 'multiline', 'protocol_version', 'quit', 'test']) proxy.close()
449,512
def test_list_commands(tc): proxy = _make_proxy() tc.assertListEqual( proxy.engine.list_commands(), ['error', 'fatal', 'gomill-passthrough', 'known_command', 'list_commands', 'multiline', 'protocol_version', 'quit', 'test']) proxy.close()
def test_list_commands(tc): proxy = _make_proxy() tc.assertListEqual( proxy.engine.list_commands(), ['error', 'fatal', 'gomill-passthrough', 'known_command', 'list_commands', 'multiline', 'protocol_version', 'quit', 'test']) fx.proxy.close()
449,513
def test_back_end_has_command(tc): proxy = _make_proxy() tc.assertTrue(proxy.back_end_has_command('test')) tc.assertFalse(proxy.back_end_has_command('xyzzy')) tc.assertFalse(proxy.back_end_has_command('gomill-passthrough'))
def test_back_end_has_command(tc): fx = Proxy_fixture(tc) tc.assertTrue(fx.proxy.back_end_has_command('test')) tc.assertFalse(fx.proxy.back_end_has_command('xyzzy')) tc.assertFalse(fx.proxy.back_end_has_command('gomill-passthrough'))
449,514
def test_passthrough(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'known_command', ['gomill-passthrough'], "true") check_engine(tc, proxy.engine, 'gomill-passthrough', ['test', 'ab', 'cd'], "args: ab cd") check_engine(tc, proxy.engine, 'gomill-passthrough', ['known_command', 'gomill-passthrough'], "false")...
def test_passthrough(tc): fx = Proxy_fixture(tc) fx.check_command('known_command', ['gomill-passthrough'], "true") fx.check_command('gomill-passthrough', ['test', 'ab', 'cd'], "args: ab cd") fx.check_command( 'gomill-passthrough', ['known_command', 'gomill-passthrough'], "false") fx.check_command('gomill-passthrough', ...
449,515
def test_passthrough(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'known_command', ['gomill-passthrough'], "true") check_engine(tc, proxy.engine, 'gomill-passthrough', ['test', 'ab', 'cd'], "args: ab cd") check_engine(tc, proxy.engine, 'gomill-passthrough', ['known_command', 'gomill-passthrough'], "false")...
def test_passthrough(tc): proxy = _make_proxy() check_engine(tc, proxy.engine, 'known_command', ['gomill-passthrough'], "true") check_engine(tc, proxy.engine, 'gomill-passthrough', ['test', 'ab', 'cd'], "args: ab cd") check_engine(tc, proxy.engine, 'gomill-passthrough', ['known_command', 'gomill-passthrough'], "false")...
449,516
def test_pass_command(tc): proxy = _make_proxy() tc.assertEqual(proxy.pass_command("test", ["ab", "cd"]), "args: ab cd") with tc.assertRaises(BadGtpResponse) as ar: proxy.pass_command("error", []) tc.assertEqual(ar.exception.gtp_error_message, "normal error") tc.assertEqual(str(ar.exception), "failure response from 'er...
def test_pass_command(tc): fx = Proxy_fixture(tc) tc.assertEqual(fx.proxy.pass_command("test", ["ab", "cd"]), "args: ab cd") with tc.assertRaises(BadGtpResponse) as ar: proxy.pass_command("error", []) tc.assertEqual(ar.exception.gtp_error_message, "normal error") tc.assertEqual(str(ar.exception), "failure response from...
449,517
def test_pass_command(tc): proxy = _make_proxy() tc.assertEqual(proxy.pass_command("test", ["ab", "cd"]), "args: ab cd") with tc.assertRaises(BadGtpResponse) as ar: proxy.pass_command("error", []) tc.assertEqual(ar.exception.gtp_error_message, "normal error") tc.assertEqual(str(ar.exception), "failure response from 'er...
def test_pass_command(tc): proxy = _make_proxy() tc.assertEqual(proxy.pass_command("test", ["ab", "cd"]), "args: ab cd") with tc.assertRaises(BadGtpResponse) as ar: fx.proxy.pass_command("error", []) tc.assertEqual(ar.exception.gtp_error_message, "normal error") tc.assertEqual(str(ar.exception), "failure response from ...
449,518
def test_pass_command_with_channel_error(tc): proxy = _make_proxy() proxy.controller.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: proxy.pass_command("test", []) tc.assertEqual(str(ar.exception), "transport error sending 'test' to testbackend:\n" "forced failure for send_command_line") tc.a...
def test_pass_command_with_channel_error(tc): fx = Proxy_fixture(tc) fx.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: fx.proxy.pass_command("test", []) tc.assertEqual(str(ar.exception), "transport error sending 'test' to testbackend:\n" "forced failure for send_command_line") tc.assertIsIns...
449,519
def test_pass_command_with_channel_error(tc): proxy = _make_proxy() proxy.controller.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: proxy.pass_command("test", []) tc.assertEqual(str(ar.exception), "transport error sending 'test' to testbackend:\n" "forced failure for send_command_line") tc.a...
def test_pass_command_with_channel_error(tc): proxy = _make_proxy() proxy.controller.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: proxy.pass_command("test", []) tc.assertEqual(str(ar.exception), "transport error sending 'test' to testbackend:\n" "forced failure for send_command_line") tc.a...
449,520
def handle_xyzzy(args): if args and args[0] == "error": return proxy.handle_command("error", []) else: return proxy.handle_command("test", ["nothing", "happens"])
def handle_xyzzy(args): if args and args[0] == "error": return fx.proxy.handle_command("error", []) else: return proxy.handle_command("test", ["nothing", "happens"])
449,521
def handle_xyzzy(args): if args and args[0] == "error": return proxy.handle_command("error", []) else: return proxy.handle_command("test", ["nothing", "happens"])
def handle_xyzzy(args): if args and args[0] == "error": return proxy.handle_command("error", []) else: return proxy.handle_command("test", ["nothing", "happens"])
449,522
def handle_xyzzy(args): return proxy.handle_command("test", [])
def handle_xyzzy(args): return proxy.handle_command("test", [])
449,523
def test_back_end_goes_away(tc): proxy = _make_proxy() tc.assertEqual(proxy.pass_command("quit", []), "") check_engine(tc, proxy.engine, 'test', ['ab', 'cd'], "error sending 'test ab cd' to testbackend:\n" "engine has closed the command channel", expect_failure=True, expect_end=True)
def test_back_end_goes_away(tc): fx = Proxy_fixture(tc) tc.assertEqual(fx.proxy.pass_command("quit", []), "") fx.check_command('test', ['ab', 'cd'], "error sending 'test ab cd' to testbackend:\n" "engine has closed the command channel", expect_failure=True, expect_end=True)
449,524
def test_close_with_errors(tc): proxy = _make_proxy() proxy.controller.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: proxy.close() tc.assertEqual(str(ar.exception), "transport error sending 'quit' to testbackend:\n" "forced failure for send_command_line") tc.assertTrue(proxy.controller.chan...
def test_close_with_errors(tc): fx = Proxy_fixture(tc) fx.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: fx.proxy.close() tc.assertEqual(str(ar.exception), "transport error sending 'quit' to testbackend:\n" "forced failure for send_command_line") tc.assertTrue(proxy.controller.channel.is_clo...
449,525
def test_close_with_errors(tc): proxy = _make_proxy() proxy.controller.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: proxy.close() tc.assertEqual(str(ar.exception), "transport error sending 'quit' to testbackend:\n" "forced failure for send_command_line") tc.assertTrue(proxy.controller.chan...
def test_close_with_errors(tc): proxy = _make_proxy() proxy.controller.channel.fail_next_command = True with tc.assertRaises(BackEndError) as ar: proxy.close() tc.assertEqual(str(ar.exception), "transport error sending 'quit' to testbackend:\n" "forced failure for send_command_line") tc.assertTrue(fx.channel.is_closed)...
449,526
def test_quit_ignores_already_closed(tc): proxy = _make_proxy() tc.assertEqual(proxy.pass_command("quit", []), "") check_engine(tc, proxy.engine, 'quit', [], "", expect_end=True) proxy.close() tc.assertEqual(proxy._commands_handled, [('list_commands', []), ('quit', [])])
def test_quit_ignores_already_closed(tc): fx = Proxy_fixture(tc) tc.assertEqual(fx.proxy.pass_command("quit", []), "") fx.check_command('quit', [], "", expect_end=True) fx.proxy.close() tc.assertEqual(fx.commands_handled, [('list_commands', []), ('quit', [])])
449,527
def force_error(args): 1 / 0
def force_error(args): 1 / 0
449,528
def force_error(args): 1 / 0
def force_error(args): 1 / 0
449,529
def test_quit_with_channel_error(tc): proxy = _make_proxy() proxy.controller.channel.fail_next_command = True check_engine(tc, proxy.engine, 'quit', [], "transport error sending 'quit' to testbackend:\n" "forced failure for send_command_line", expect_failure=True, expect_end=True) proxy.close() tc.assertEqual(proxy._co...
def test_quit_with_channel_error(tc): fx = Proxy_fixture(tc) fx.channel.fail_next_command = True fx.check_command('quit', [], "transport error sending 'quit' to testbackend:\n" "forced failure for send_command_line", expect_failure=True, expect_end=True) fx.proxy.close() tc.assertEqual(fx.commands_handled, [('list_comm...
449,530
def coords_from_vertex(vertex, board_size): """Interpret a string representing a vertex, as specified by GTP. Returns a pair of coordinates (row, col) in range(0, board_size) Raises ValueError with an appropriate message if 'arg' isn't a valid GTP vertex specification for a board of size 'board_size'. """ if not 0 <...
def coords_from_vertex(vertex, board_size): """Interpret a string representing a vertex, as specified by GTP. Returns a pair of coordinates (row, col) in range(0, board_size) Raises ValueError with an appropriate message if 'vertex' isn't a valid GTP vertex specification for a board of size 'board_size'. """ if not ...
449,531
def game_jobs_player_from_config(self, code, player_config): """Make a game_jobs.Player from a Player_config.
def game_jobs_player_from_config(self, code, player_config): """Make a game_jobs.Player from a Player_config.
449,532
def handle_final_score_b(args): if isinstance(b_score, Exception): raise b_score return b_score
def handle_final_score_b(args): if b_score is Exception: raise b_score return b_score
449,533
def handle_final_score_w(args): if isinstance(w_score, Exception): raise w_score return w_score
def handle_final_score_w(args): if w_score is Exception: raise w_score return w_score
449,534
def test_players_score_one_illformed(tc): fx = Game_fixture(tc) fx.run_score_test("black wins", "W+4") tc.assertEqual(fx.game.result.sgf_result, "W+4") tc.assertIsNone(fx.game.result.detail) tc.assertEqual(fx.game.result.winning_colour, 'w')
def test_players_score_one_illformed(tc): fx = Game_fixture(tc) fx.run_score_test("black wins", "W+4.5") tc.assertEqual(fx.game.result.sgf_result, "W+4.5") tc.assertIsNone(fx.game.result.detail) tc.assertEqual(fx.game.result.winning_colour, 'w') tc.assertEqual(fx.game.describe_scoring(), "two beat one W+4.5\n" "one fin...
449,535
def test_players_score_agree_except_margin(tc): fx = Game_fixture(tc) fx.run_score_test("b+3", "B+4") tc.assertEqual(fx.game.result.sgf_result, "B+") tc.assertEqual(fx.game.result.detail, "unknown margin") tc.assertEqual(fx.game.result.winning_colour, 'b')
def test_players_score_agree_except_margin(tc): fx = Game_fixture(tc) fx.run_score_test("b+3", "B+4.0") tc.assertEqual(fx.game.result.sgf_result, "B+") tc.assertEqual(fx.game.result.detail, "unknown margin") tc.assertEqual(fx.game.result.winning_colour, 'b')
449,536
def __init__(self, fn): unittest2.TestCase.__init__(self) self.fn = fn try: self.name = fn.__module__.split(".", 1)[-1] + "." + fn.__name__ except AttributeError: self.name = str(fn)
def __init__(self, fn): FrameworkTestCase.__init__(self) self.fn = fn try: self.name = fn.__module__.split(".", 1)[-1] + "." + fn.__name__ except AttributeError: self.name = str(fn)
449,537
def render(self, s, width): if self.align == 'left': s = s.ljust(width) elif self.align == 'right': s = s.rjust(width) return s + " " * self.right_padding
def render(self, s, width): if self.align == 'left': s = s.ljust(width) elif self.align == 'right': s = s.rjust(width) return s + " " * self.right_padding
449,538
def p(s): print >>out, s
def p(s): print >>out, s
449,539
def p(s): print >>out, s
def p(s): print >>out, s
449,540
def calculate_cpu_times(self): """Set CPU times in self.result.
def calculate_cpu_times(self): """Set CPU times in self.result.
449,541
def openid_is_authorized(req, identity_url, trust_root): """ Check that they own the given identity URL, and that the trust_root is in their whitelist of trusted sites. """ if not req.user.is_authenticated(): return None openid = openid_get_identity(req, identity_url) if openid is None: return None import logging LOG...
def openid_is_authorized(req, identity_url, trust_root): """ Check that they own the given identity URL, and that the trust_root is in their whitelist of trusted sites. """ if not req.user.is_authenticated(): return None openid = openid_get_identity(req, identity_url) if openid is None: return None if openid.trustedr...
449,542
def landing_page(request, orequest): """ The page shown when the user attempts to sign in somewhere using OpenID but is not authenticated with the site. For idproxy.net, a message telling them to log in manually is displayed. """ request.session['OPENID_REQUEST'] = orequest login_url = settings.LOGIN_URL path = request...
def landing_page(request, orequest): """ The page shown when the user attempts to sign in somewhere using OpenID but is not authenticated with the site. For idproxy.net, a message telling them to log in manually is displayed. """ request.session['OPENID_REQUEST'] = orequest login_url = settings.LOGIN_URL path = request...
449,543
def nextURL(self): url = self.url(self.context) return url
def nextURL(self): url = self.url(self.context) return url
449,544
def nextURL(self): url = self.url(self.context) return url
def nextURL(self): url = self.url(self.context) return url
449,545
def nextURL(self): url = self.url(self.context) return url
def nextURL(self): url = self.url(self.context) return url
449,546
def renderCell(self, item): return item.geburtsdatum.strftime('%d.%m.%Y')
def renderCell(self, item): return item.geburtsdatum.strftime('%d.%m.%Y')
449,547
def findOn(self,path):
def findOn(self,path):
449,548
def findOn(self,path):
def findOn(self,path):
449,549
def findOn(self,path):
def findOn(self,path):
449,550
def findOn(self,path):
def findOn(self,path):
449,551
def findOn(self,path):
def findOn(self,path):
449,552
def commit(self): 'called when backup has acknowledged checkpoint reception' pass
def commit(self): 'called when backup has acknowledged checkpoint reception' pass
449,553
def commit(self): msg = os.read(self.msgfd.fileno(), 4) if msg != 'done': print 'Unknown message: %s' % msg
def commit(self): msg = os.read(self.msgfd.fileno(), 4) if msg != 'done': print 'Unknown message: %s' % msg
449,554
def commit(self): msg = os.read(self.msgfd.fileno(), 4) if msg != 'done': print 'Unknown message: %s' % msg
def commit(self): msg = os.read(self.msgfd.fileno(), 4) if msg != 'done': print 'Unknown message: %s' % msg
449,555
def __init__(self, domid): self.installed = False
def __init__(self, domid): self.installed = False
449,556
def postsuspend(self): if not self.installed: self._setup()
def postsuspend(self): if not self.installed: self._setup()
449,557
def _sendqmsg(self, action): self.q.action = action req = qdisc.changerequest(self.dev, self.handle, self.q) self.rth.talk(req.pack())
def _sendqmsg(self, action): self.q.action = action req = qdisc.changerequest(self.bufdevno, self.handle, self.q) self.rth.talk(req.pack())
449,558
def _sendqmsg(self, action): self.q.action = action req = qdisc.changerequest(self.dev, self.handle, self.q) self.rth.talk(req.pack())
def _sendqmsg(self, action): self.q.action = action req = qdisc.changerequest(self.dev, self.handle, self.q) self.rth.talk(req.pack())
449,559
def _setup(self): q = self.rth.getqdisc(self.dev) if q: if q['kind'] == 'queue': self.installed = True return if q['kind'] != 'pfifo_fast': raise BufferedNICException('there is already a queueing ' 'discipline on %s' % self.devname)
def _setup(self): q = self.rth.getqdisc(self.dev) if q: if q['kind'] == 'queue': self.installed = True return if q['kind'] != 'pfifo_fast': raise BufferedNICException('there is already a queueing ' 'discipline on %s' % self.devname)
449,560
def uninstall(self): if self.installed: req = qdisc.delrequest(self.dev, self.handle) self.rth.talk(req.pack()) self.installed = False
def uninstall(self): if self.installed: req = qdisc.delrequest(self.bufdevno, self.handle) self.rth.talk(req.pack()) self.installed = False
449,561
def _startimq(self, domid): # stopgap hack to set up IMQ for an interface. Wrong in many ways. imqebt = '/usr/lib/xen/bin/imqebt' imqdev = 'imq0' vid = 'vif%d.0' % domid for mod in ['sch_queue', 'imq', 'ebt_imq']: util.runcmd(['modprobe', mod]) util.runcmd("ip link set %s up" % (imqdev)) util.runcmd("%s -F FORWARD" % (...
def _startimq(self, domid): # stopgap hack to set up IMQ for an interface. Wrong in many ways. imqebt = '/usr/lib/xen/bin/imqebt' imqdev = 'imq0' vid = 'vif%d.0' % domid for mod in ['sch_queue', 'imq', 'ebt_imq']: util.runcmd(['modprobe', mod]) util.runcmd("ip link set %s up" % (imqdev)) util.runcmd("%s -F FORWARD" % (...
449,562
def __str__(self): return 'VM %d (%s), MACs: [%s], disks: [%s]' % \ (self.domid, self.name, self.epoch, ', '.join(self.macs), ', '.join([str(d) for d in self.disks]))
def __str__(self): return 'VM %d (%s), vifs: [%s], disks: [%s]' % \ (self.domid, self.name, ', '.join([str(v) for v in self.vifs]), ', '.join([str(d) for d in self.disks]))
449,563
def do_FLR(self, is_hvm, strict_check): """ Perform FLR (Functional Level Reset) for the device. """ if self.dev_type == DEV_TYPE_PCIe_ENDPOINT: # If PCIe device supports FLR, we use it. if self.pcie_flr: (pci_list, cfg_list) = save_pci_conf_space([self.name]) pos = self.find_cap_offset(PCI_CAP_ID_EXP) self.pci_conf_wr...
def do_FLR(self, is_hvm, strict_check): """ Perform FLR (Functional Level Reset) for the device. """ if self.dev_type == DEV_TYPE_PCIe_ENDPOINT: # If PCIe device supports FLR, we use it. if self.pcie_flr: (pci_list, cfg_list) = save_pci_conf_space([self.name]) pos = self.find_cap_offset(PCI_CAP_ID_EXP) self.pci_conf_wr...
449,564
def do_FLR(self, is_hvm, strict_check): """ Perform FLR (Functional Level Reset) for the device. """ if self.dev_type == DEV_TYPE_PCIe_ENDPOINT: # If PCIe device supports FLR, we use it. if self.pcie_flr: (pci_list, cfg_list) = save_pci_conf_space([self.name]) pos = self.find_cap_offset(PCI_CAP_ID_EXP) self.pci_conf_wr...
def do_FLR(self, is_hvm, strict_check): """ Perform FLR (Functional Level Reset) for the device. """ if self.dev_type == DEV_TYPE_PCIe_ENDPOINT: # If PCIe device supports FLR, we use it. if self.pcie_flr: (pci_list, cfg_list) = save_pci_conf_space([self.name]) pos = self.find_cap_offset(PCI_CAP_ID_EXP) self.pci_conf_wr...
449,565
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" t = xstransact("%s/device" % self.vmpath) if self.image: try: for dev in t.list('tap'): log.debug("Early removing %s", dev); self.getDeviceController('tap').destroyDevice(dev, True) time.sleep(0.1) log.debug("Destroying ...
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" if self.image: try: for dev in t.list('tap'): log.debug("Early removing %s", dev); self.getDeviceController('tap').destroyDevice(dev, True) time.sleep(0.1) log.debug("Destroying device model") self.image.destroyDeviceMod...
449,566
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" t = xstransact("%s/device" % self.vmpath) if self.image: try: for dev in t.list('tap'): log.debug("Early removing %s", dev); self.getDeviceController('tap').destroyDevice(dev, True) time.sleep(0.1) log.debug("Destroying ...
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" t = xstransact("%s/device" % self.vmpath) if self.image: try: log.debug("Destroying device model") self.image.destroyDeviceModel() except Exception, e: log.exception("Device model destroy failed %s" % str(e)) else: log.d...
449,567
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" t = xstransact("%s/device" % self.vmpath) if self.image: try: for dev in t.list('tap'): log.debug("Early removing %s", dev); self.getDeviceController('tap').destroyDevice(dev, True) time.sleep(0.1) log.debug("Destroying ...
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" t = xstransact("%s/device" % self.vmpath) if self.image: try: for dev in t.list('tap'): log.debug("Early removing %s", dev); self.getDeviceController('tap').destroyDevice(dev, True) time.sleep(0.1) log.debug("Destroying ...
449,568
def convert_on_crash(v): v = str(v) return XEN_API_ON_CRASH_BEHAVIOUR_LEGACY[v] \ if v in XEN_API_ON_CRASH_BEHAVIOUR else v
def convert_on_crash(v): v = str(v) if v in XEN_API_ON_CRASH_BEHAVIOUR: return XEN_API_ON_CRASH_BEHAVIOUR_LEGACY[v] else: return v
449,569
def scrub_password(data): if type(data) == dict or type(data) == XendConfig: scrubbed = {} for key in data.keys(): if key == "vncpasswd": scrubbed[key] = "XXXXXXXX" else: scrubbed[key] = scrub_password(data[key]) return scrubbed elif type(data) == list: if len(data) == 2 and type(data[0]) == str and data[0] == 'vncpass...
def scrub_password(data): if type(data) == dict or type(data) == XendConfig: scrubbed = {} for key in data.keys(): if key == "vncpasswd": scrubbed[key] = "XXXXXXXX" else: scrubbed[key] = scrub_password(data[key]) return scrubbed elif type(data) == list: if len(data) == 2 and type(data[0]) == str and data[0] == 'vncpass...
449,570
def scrub_password(data): if type(data) == dict or type(data) == XendConfig: scrubbed = {} for key in data.keys(): if key == "vncpasswd": scrubbed[key] = "XXXXXXXX" else: scrubbed[key] = scrub_password(data[key]) return scrubbed elif type(data) == list: if len(data) == 2 and type(data[0]) == str and data[0] == 'vncpass...
def scrub_password(data): if type(data) == dict or type(data) == XendConfig: scrubbed = {} for key in data.keys(): if key == "vncpasswd": scrubbed[key] = "XXXXXXXX" else: scrubbed[key] = scrub_password(data[key]) return scrubbed elif type(data) == list: if len(data) == 2 and type(data[0]) == str and data[0] == 'vncpass...
449,571
def pack(self): self.rta_len = align(self.fmtlen + len(self.body)) s = struct.pack(self.fmt, self.rta_len, self.rta_type) + self.body pad = self.rta_len - len(s) if pad: s += '\0' * pad return s
def pack(self): self.rta_len = self.fmtlen + align(len(self.body), 2) s = struct.pack(self.fmt, self.rta_len, self.rta_type) + self.body pad = self.rta_len - len(s) if pad: s += '\0' * pad return s
449,572
def unpack(self, msg): args = struct.unpack(self.fmt, msg[:self.fmtlen]) self.rta_len, self.rta_type = args
def unpack(self, msg): args = struct.unpack(self.fmt, msg[:self.fmtlen]) self.rta_len, self.rta_type = args
449,573
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" if self.image: try: log.debug("Destroying device model") self.image.destroyDeviceModel() except Exception, e: log.exception("Device model destroy failed %s" % str(e)) else: log.debug("No device model")
def _releaseDevices(self, suspend = False): """Release all domain's devices. Nothrow guarantee.""" if self.image: try: log.debug("Destroying device model") self.image.destroyDeviceModel() except Exception, e: log.exception("Device model destroy failed %s" % str(e)) else: log.debug("No device model")
449,574
def _vscsi_get_scsidevices_by_lsscsi(option = ""): """ get all scsi devices information by lsscsi """ devices = [] for scsiinfo in os.popen('{ lsscsi -g %s; } 2>/dev/null' % option).readlines(): s = scsiinfo.split() hctl = s[0][1:-1] try: devname = s[-2].split('/dev/')[1] except IndexError: devname = None try: sg = s...
def _vscsi_get_scsidevices_by_lsscsi(option = ""): """ get all scsi devices information by lsscsi """ devices = [] for scsiinfo in os.popen('{ lsscsi -g %s; } 2>/dev/null' % option).readlines(): s = scsiinfo.replace(']', '] ').split() hctl = s[0][1:-1] try: devname = s[-2].split('/dev/')[1] except IndexError: devname...
449,575
def check_dtd(self, file): """ Check file against DTD. Use this if possible as it gives nice error messages """ dtd = xmldtd.load_dtd(self.dtd) parser = xmlproc.XMLProcessor() parser.set_application(xmlval.ValidatingApp(dtd, parser)) parser.dtd = dtd parser.ent = dtd parser.parse_resource(file)
def check_dtd(self, file): """ Check file against DTD. Use this if possible as it gives nice error messages """ dtd = xmldtd.load_dtd(self.dtd) parser = xmlproc.XMLProcessor() parser.set_application(xmlval.ValidatingApp(dtd, parser)) parser.dtd = dtd parser.ent = dtd parser.parse_resource(file)
449,576
def check_dom_against_dtd(self, dom): """ Check DOM again DTD. Doesn't give as nice error messages. (no location info) """ dtd = xmldtd.load_dtd(self.dtd) app = xmlval.ValidatingApp(dtd, self) app.set_locator(self) self.dom2sax(dom, app)
def check_dom_against_dtd(self, dom): """ Check DOM again DTD. Doesn't give as nice error messages. (no location info) """ dtd = xmldtd.load_dtd(self.dtd) app = xmlval.ValidatingApp(dtd, self) app.set_locator(self) self.dom2sax(dom, app)
449,577
def report_error(self, number, args=None): self.errors = xmlproc.errors.english try: msg = self.errors[number] if args != None: msg = msg % args except KeyError: msg = self.errors[4002] % number # Unknown err msg :-) print msg sys.exit(-1)
def report_error(self, number, args=None): self.errors = xmlproc.errors.english try: msg = self.errors[number] if args != None: msg = msg % args except KeyError: msg = self.errors[4002] % number # Unknown err msg :-) print msg sys.exit(-1)
449,578
def report_error(self, number, args=None): self.errors = xmlproc.errors.english try: msg = self.errors[number] if args != None: msg = msg % args except KeyError: msg = self.errors[4002] % number # Unknown err msg :-) print msg sys.exit(-1)
def report_error(self, number, args=None): self.errors = xmlproc.errors.english try: msg = self.errors[number] if args != None: msg = msg % args except KeyError: msg = self.errors[4002] % number # Unknown err msg :-) print msg sys.exit(-1)
449,579
def blkdev_name_to_number(name): """Take the given textual block-device name (e.g., '/dev/sda1', 'hda') and return the device number used by the OS. """ n = expand_dev_name(name) devname = 'virtual-device' devnum = None try: return (devname, os.stat(n).st_rdev) except Exception, ex: pass scsi_major = [ 8, 65, 66, 6...
def blkdev_name_to_number(name): """Take the given textual block-device name (e.g., '/dev/sda1', 'hda') and return the device number used by the OS. """ n = expand_dev_name(name) devname = 'virtual-device' devnum = None scsi_major = [ 8, 65, 66, 67, 68, 69, 70, 71, 128, 129, 130, 131, 132, 133, 134, 135 ] if re.matc...
449,580
def createDeviceModel(self, restore = False): if self.device_model is None: return if self.pid: return # Execute device model. #todo: Error handling args = self.getDeviceModelArgs(restore) env = dict(os.environ) if self.display: env['DISPLAY'] = self.display if self.xauthority: env['XAUTHORITY'] = self.xauthority uniqu...
def createDeviceModel(self, restore = False): if self.device_model is None: return if self.pid: return # Execute device model. #todo: Error handling args = self.getDeviceModelArgs(restore) env = dict(os.environ) if self.display: env['DISPLAY'] = self.display if self.xauthority: env['XAUTHORITY'] = self.xauthority uniqu...
449,581
def find_relaxed_node(node_list): import sys nr_nodes = info['nr_nodes'] if node_list is None: node_list = range(0, nr_nodes) nodeload = [0] nodeload = nodeload * nr_nodes from xen.xend import XendDomain doms = XendDomain.instance().list('all') for dom in filter (lambda d: d.domid != self.domid, doms): cpuinfo = dom.ge...
def find_relaxed_node(node_list): import sys nr_nodes = info['nr_nodes'] if node_list is None: node_list = range(0, nr_nodes) nodeload = [0] nodeload = nodeload * nr_nodes from xen.xend import XendDomain doms = XendDomain.instance().list('all') for dom in filter (lambda d: d.domid != self.domid, doms): cpuinfo = dom.ge...
449,582
def find_relaxed_node(node_list): import sys nr_nodes = info['nr_nodes'] if node_list is None: node_list = range(0, nr_nodes) nodeload = [0] nodeload = nodeload * nr_nodes from xen.xend import XendDomain doms = XendDomain.instance().list('all') for dom in filter (lambda d: d.domid != self.domid, doms): cpuinfo = dom.ge...
def find_relaxed_node(node_list): import sys nr_nodes = info['nr_nodes'] if node_list is None: node_list = range(0, nr_nodes) nodeload = [0] nodeload = nodeload * nr_nodes from xen.xend import XendDomain doms = XendDomain.instance().list('all') for dom in filter (lambda d: d.domid != self.domid, doms): cpuinfo = dom.ge...
449,583
def device_create(self, dev_config): """Create a new device.
def device_create(self, dev_config): """Create a new device.
449,584
def get_xend_tcp_xmlrpc_server_ssl_key_file(self): name = 'xend-tcp-xmlrpc-server-ssl-key-file' file = self.get_config_string(name) if os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" % (name, fi...
def get_xend_tcp_xmlrpc_server_ssl_key_file(self): name = 'xend-tcp-xmlrpc-server-ssl-key-file' file = self.get_config_string(name) if file and os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" % ...
449,585
def get_xend_tcp_xmlrpc_server_ssl_key_file(self): name = 'xend-tcp-xmlrpc-server-ssl-key-file' file = self.get_config_string(name) if os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" % (name, fi...
def get_xend_tcp_xmlrpc_server_ssl_key_file(self): name = 'xend-tcp-xmlrpc-server-ssl-key-file' file = self.get_config_string(name) if os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if file and not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" % ...
449,586
def get_xend_tcp_xmlrpc_server_ssl_cert_file(self): name = 'xend-tcp-xmlrpc-server-ssl-cert-file' file = self.get_config_string(name) if os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" % (name, ...
def get_xend_tcp_xmlrpc_server_ssl_cert_file(self): name = 'xend-tcp-xmlrpc-server-ssl-cert-file' file = self.get_config_string(name) if file and os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" ...
449,587
def get_xend_tcp_xmlrpc_server_ssl_cert_file(self): name = 'xend-tcp-xmlrpc-server-ssl-cert-file' file = self.get_config_string(name) if os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" % (name, ...
def get_xend_tcp_xmlrpc_server_ssl_cert_file(self): name = 'xend-tcp-xmlrpc-server-ssl-cert-file' file = self.get_config_string(name) if os.path.dirname(file) == "": file = auxbin.xen_configdir() + '/' + file; if file and not os.path.exists(file): raise XendError("invalid xend config %s: directory '%s' does not exist" ...
449,588
def xm_network_list(args): (use_long, params) = arg_check_for_resource_list(args, "network-list") dom = params[0] if serverType == SERVER_XEN_API: vif_refs = server.xenapi.VM.get_VIFs(get_single_vm(dom)) vif_properties = \ map(server.xenapi.VIF.get_runtime_properties, vif_refs) devs = map(lambda (handle, properties):...
def xm_network_list(args): (use_long, params) = arg_check_for_resource_list(args, "network-list") dom = params[0] if serverType == SERVER_XEN_API: vif_refs = server.xenapi.VM.get_VIFs(get_single_vm(dom)) vif_properties = [] for vif_ref in vif_refs: vif_property = server.xenapi.VIF.get_runtime_properties(vif_ref) vif_...
449,589
def restore(xd, fd, dominfo = None, paused = False, relocating = False): try: if not os.path.isdir("/var/lib/xen"): os.makedirs("/var/lib/xen") except Exception, exn: log.exception("Can't create directory '/var/lib/xen'") raise XendError("Can't create directory '/var/lib/xen'") signature = read_exact(fd, len(SIGNATURE...
def restore(xd, fd, dominfo = None, paused = False, relocating = False): try: if not os.path.isdir("/var/lib/xen"): os.makedirs("/var/lib/xen") except Exception, exn: log.exception("Can't create directory '/var/lib/xen'") raise XendError("Can't create directory '/var/lib/xen'") signature = read_exact(fd, len(SIGNATURE...
449,590
def __repr__(self): if self.part is not None: return "d%dp%d" %(self.disk, self.part) else: return "d%d" %(self,disk,)
def __repr__(self): if self.part is not None: return "d%dp%d" %(self.disk, self.part) else: return "d%d" %(self,disk,)
449,591
def getStubdomDomid(self): dom_list = xstransact.List('/local/domain') for d in dom_list: target = xstransact.Read('/local/domain/' + d + '/target') if target is not None and int(target) is self.domid : return int(d) return None
def getStubdomDomid(self): dom_list = xstransact.List('/local/domain') for d in dom_list: target = xstransact.Read('/local/domain/' + d + '/target') if target is not None and int(target) == self.domid: return int(d) return None
449,592
def parseDeviceModelArgs(self, vmConfig): ret = ImageHandler.parseDeviceModelArgs(self, vmConfig) ret = ret + ['-vcpus', str(self.vm.getVCpuCount())] ret = ret + ['-vcpu_avail', str(self.vm.getVCpuAvail())]
def parseDeviceModelArgs(self, vmConfig): ret = ImageHandler.parseDeviceModelArgs(self, vmConfig) ret = ret + ['-vcpus', str(self.vm.getVCpuCount())] ret = ret + ['-vcpu_avail', str(self.vm.getVCpuAvail())]
449,593
def format_comment(level, comment): indent = reduce(lambda x,y: x + " ", range(level), "") s = "%s/*\n" % indent s += "%s * " % indent comment = comment.replace("\n", "\n%s * " % indent) x = re.compile(r'^%s \* $' % indent, re.MULTILINE) comment = x.sub("%s *" % indent, comment) s += comment s += "\n" s += "%s */" % i...
class Builtin(Type): """Builtin type""" def __init__(self, typename, **kwargs): Type.__init__(self, typename, **kwargs)
449,594
def libxl_C_type_of(ty): return ty.typename
class UInt(Type): def __init__(self, w, **kwargs): kwargs.setdefault('namespace', None) Type.__init__(self, "uint%d_t" % w, **kwargs)
449,595
def libxl_C_instance_of(ty, instancename): if isinstance(ty, libxltypes.BitField): return libxl_C_type_of(ty) + " " + instancename + ":%d" % ty.width elif isinstance(ty, libxltypes.Aggregate) and ty.typename is None: if instancename is None: return libxl_C_type_define(ty) else: return libxl_C_type_define(ty) + " " + in...
self.width = w
449,596
def libxl_C_type_define(ty, indent = ""): s = "" if isinstance(ty, libxltypes.Aggregate): if ty.comment is not None: s += format_comment(0, ty.comment) if ty.typename is None: s += "%s {\n" % ty.kind else: s += "typedef %s {\n" % ty.kind for f in ty.fields: if f.comment is not None: s += format_comment(4, f.comment) ...
class BitField(Type): def __init__(self, ty, w, **kwargs): kwargs.setdefault('namespace', None) Type.__init__(self, ty.typename, **kwargs) if ty.typename is None: s += "%s {\n" % ty.kind else: s += "typedef %s {\n" % ty.kind for f in ty.fields: if f.comment is not None: s += format_comment(4, f.comment) x = libxl_C_i...
449,597
def libxl_C_type_define(ty, indent = ""): s = "" if isinstance(ty, libxltypes.Aggregate): if ty.comment is not None: s += format_comment(0, ty.comment) if ty.typename is None: s += "%s {\n" % ty.kind else: s += "typedef %s {\n" % ty.kind for f in ty.fields: if f.comment is not None: s += format_comment(4, f.comment) ...
def libxl_C_type_define(ty, indent = ""): s = "" if isinstance(ty, libxltypes.Aggregate): if ty.comment is not None: s += format_comment(0, ty.comment) self.width = w for f in ty.fields: if f.comment is not None: s += format_comment(4, f.comment) x = libxl_C_instance_of(f.type, f.name) if f.const: x = "const " + x x ...
449,598
s += "typedef %s {\n" % ty.kind
s += "typedef %s {\n" % ty.kind
449,599