当前位置: 首页>>代码示例>>Python>>正文


Python emulator.Emulator类代码示例

本文整理汇总了Python中emulator.Emulator的典型用法代码示例。如果您正苦于以下问题:Python Emulator类的具体用法?Python Emulator怎么用?Python Emulator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Emulator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

    def __init__(self, host='localhost', port=2828, emulator=False,
                 connectToRunningEmulator=False, homedir=None,
                 baseurl=None, noWindow=False):
        self.host = host
        self.port = self.local_port = port
        self.session = None
        self.window = None
        self.emulator = None
        self.homedir = homedir
        self.baseurl = baseurl
        self.noWindow = noWindow

        if emulator:
            self.emulator = Emulator(homedir=homedir, noWindow=self.noWindow)
            self.emulator.start()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        if connectToRunningEmulator:
            self.emulator = Emulator(homedir=homedir)
            self.emulator.connect()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        self.client = MarionetteClient(self.host, self.port)
开发者ID:malini,项目名称:marionette_client,代码行数:25,代码来源:marionette.py

示例2: __init__

    def __init__(self, host='localhost', port=2828, b2gbin=False,
                 emulator=None, connectToRunningEmulator=False,
                 homedir=None, baseurl=None, noWindow=False, logcat_dir=None):
        self.host = host
        self.port = self.local_port = port
        self.b2gbin = b2gbin
        self.session = None
        self.window = None
        self.emulator = None
        self.extra_emulators = []
        self.homedir = homedir
        self.baseurl = baseurl
        self.noWindow = noWindow
        self.logcat_dir = logcat_dir

        if b2gbin:
            self.b2ginstance = B2GInstance(host=self.host, port=self.port, b2gbin=self.b2gbin)
            self.b2ginstance.start()
            assert(self.b2ginstance.wait_for_port())
        if emulator:
            self.emulator = Emulator(homedir=homedir,
                                     noWindow=self.noWindow,
                                     logcat_dir=self.logcat_dir,
                                     arch=emulator)
            self.emulator.start()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        if connectToRunningEmulator:
            self.emulator = Emulator(homedir=homedir, logcat_dir=self.logcat_dir)
            self.emulator.connect()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        self.client = MarionetteClient(self.host, self.port)
开发者ID:marshall,项目名称:mozilla-central,代码行数:35,代码来源:marionette.py

示例3: evaluate

def evaluate():
    #Set this color as the default
    print white, ''

    maps_list = glob.glob('maps/*.map')
    maps_list.sort()

    maps_points = {}
    maps_points_old = {}

    if os.path.exists(cache_file):
        maps_points_old = pickle.load(open(cache_file, 'r'))

    for map_file in maps_list:
        lines = []
        map_data = open(map_file, 'r')
        for line in map_data: 
            lines.append(line)
        
        m_lifter = meta_lifter.MetaLifter()
        m_lifter.hide_print = True
        commands = m_lifter.lift(lines)
        emu = Emulator(open(map_file, 'r'), commands)
        emu.suppress_prints = True
        emu.print_points = False

        while not emu.quit:
            emu.processCommand()

        points = emu.points

        maps_points[map_file] = points

        delta_points = 0
        delta_value = ''

        #Check cache...
        old_points = maps_points_old.get(map_file)
        if old_points:
            delta_points = points - old_points
            if old_points > points:
                color = red
            elif old_points < points:
                delta_value = '+'
                color = green
            else:
                color = brown

        else:
            color = brown

        if delta_points == 0:
            delta_points = ''

        print map_file, '\t' + color + str(points) + ' ' + delta_value + str(delta_points) + white

    #Dump to the cache
    pickle.dump(maps_points, open(cache_file, 'w'))
开发者ID:chris-hudson,项目名称:ICFP,代码行数:58,代码来源:evaluate_meta.py

示例4: __init__

    def __init__(self, host='localhost', port=2828, bin=None, profile=None,
                 emulator=None, sdcard=None, emulatorBinary=None,
                 emulatorImg=None, emulator_res=None, gecko_path=None,
                 connectToRunningEmulator=False, homedir=None, baseurl=None,
                 noWindow=False, logcat_dir=None, busybox=None, symbols_path=None):
        self.host = host
        self.port = self.local_port = port
        self.bin = bin
        self.instance = None
        self.profile = profile
        self.session = None
        self.window = None
        self.emulator = None
        self.extra_emulators = []
        self.homedir = homedir
        self.baseurl = baseurl
        self.noWindow = noWindow
        self.logcat_dir = logcat_dir
        self._test_name = None
        self.symbols_path = symbols_path

        if bin:
            port = int(self.port)
            if not Marionette.is_port_available(port, host=self.host):
                ex_msg = "%s:%d is unavailable." % (self.host, port)
                raise MarionetteException(message=ex_msg)
            self.instance = GeckoInstance(host=self.host, port=self.port,
                                          bin=self.bin, profile=self.profile)
            self.instance.start()
            assert(self.wait_for_port())

        if emulator:
            self.emulator = Emulator(homedir=homedir,
                                     noWindow=self.noWindow,
                                     logcat_dir=self.logcat_dir,
                                     arch=emulator,
                                     sdcard=sdcard,
                                     emulatorBinary=emulatorBinary,
                                     userdata=emulatorImg,
                                     res=emulator_res)
            self.emulator.start()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        if connectToRunningEmulator:
            self.emulator = Emulator(homedir=homedir,
                                     logcat_dir=self.logcat_dir)
            self.emulator.connect()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        self.client = MarionetteClient(self.host, self.port)

        if emulator:
            self.emulator.setup(self,
                                gecko_path=gecko_path,
                                busybox=busybox)
开发者ID:Tripleman,项目名称:mozilla-central,代码行数:57,代码来源:marionette.py

示例5: __init__

    def __init__(self):
        self.session = tf.InteractiveSession()

        self.emulator = Emulator(settings)
        settings['num_actions'] = len(self.emulator.actions)
        self.replay = ReplayDB(settings)

        with tf.variable_scope('model'):
            self.model = Model(settings)

        self.summary = tf.merge_all_summaries()
        self.writer = tf.train.SummaryWriter('summary-log', self.session.graph_def)

        self.session.run(tf.initialize_all_variables())

        self.saver = tf.train.Saver(max_to_keep=1000000)
        checkpoint = tf.train.get_checkpoint_state("networks")
        if checkpoint and checkpoint.model_checkpoint_path:
            self.saver.restore(self.session, checkpoint.model_checkpoint_path)
            print("Loaded checkpoint: {}".format(checkpoint.model_checkpoint_path))
        else:
            print("Unable to load checkpoint")

        self.summary_cnt = 0
        self.episode_cnt = 0
        self.timer = self.session.run(self.model.global_step)
        self.no_op = tf.no_op()
开发者ID:amharc,项目名称:jnp3,代码行数:27,代码来源:engine.py

示例6: __init__

    def __init__(self, name, options={}):
        self.fullname = name
        self.shortname = utils.idx(options, 'nickname', name)
        self.extensions = utils.idx(options, 'extensions', "")
        self.custom_roms_directory = utils.idx(options, 'roms directory', None)
        self.prefix = utils.idx(options, 'prefix', None)
        self.icon = os.path.expanduser(utils.idx(options, 'icon', ""))

        self.emulator = Emulator.lookup(utils.idx(options, 'emulator', ""))
开发者ID:fizzduden,项目名称:Ice,代码行数:9,代码来源:console.py

示例7: __init__

    def __init__(self, name, options={}):
        self.fullname = name
        self.shortname = utils.idx(options, "nickname", name)
        self.extensions = utils.idx(options, "extensions", "")
        self.custom_roms_directory = utils.idx(options, "roms directory", None)
        self.prefix = utils.idx(options, "prefix", "")
        self.icon = os.path.expanduser(utils.idx(options, "icon", ""))
        self.images_directory = os.path.expanduser(utils.idx(options, "images directory", ""))

        self.emulator = Emulator.lookup(utils.idx(options, "emulator", ""))
开发者ID:johnjbroderick3,项目名称:Ice,代码行数:10,代码来源:console.py

示例8: launch

def launch():
    if request.headers.get('authorization', None) != settings.LAUNCH_AUTH_HEADER:
        abort(403)
    if len(emulators) >= settings.EMULATOR_LIMIT:
        abort(503)
    uuid = uuid4()
    if '/' in request.form['platform'] or '/' in request.form['version']:
        abort(400)
    emu = Emulator(
        request.form['token'],
        request.form['platform'],
        request.form['version'],
        tz_offset=(int(request.form['tz_offset']) if 'tz_offset' in request.form else None),
        oauth=request.form.get('oauth', None)
    )
    emulators[uuid] = emu
    emu.last_ping = now()
    emu.run()
    return jsonify(uuid=uuid, ws_port=emu.ws_port, vnc_display=emu.vnc_display, vnc_ws_port=emu.vnc_ws_port)
开发者ID:boredwookie,项目名称:cloudpebble-qemu-controller,代码行数:19,代码来源:controller.py

示例9: __init__

    def __init__(self,map_file):
        self.emu = Emulator(open(map_file, 'r'), '')
        self.emu.suppress_prints = True
        self.MAX_DEPTH = self.emu.command_limit
        self.MAX_LEAVES = 10000000
        self.MAX_SCORE = 75.0*self.emu.total_lambdas
        print 'MAX DEPTH: ' + str(self.MAX_DEPTH)
        print 'MAX LEAVES: ' + str(self.MAX_LEAVES)
        print 'MAX SCORE: ' + str(self.MAX_SCORE)

        self.best_score = 0.0
        self.best_seed = -1
        self.best_path = ''    
开发者ID:chris-hudson,项目名称:ICFP,代码行数:13,代码来源:lifter2.py

示例10: __init__

    def __init__(self):
        self.session = tf.InteractiveSession()

        self.emulator = Emulator(settings)
        settings['num_actions'] = len(self.emulator.actions)

        with tf.variable_scope('model'):
            self.model = Model(settings)

        self.session.run(tf.initialize_all_variables())

        self.saver = tf.train.Saver(max_to_keep=1000000)
        checkpoint = tf.train.get_checkpoint_state("networks")
        if checkpoint and checkpoint.model_checkpoint_path:
            self.saver.restore(self.session, checkpoint.model_checkpoint_path)
            print("Loaded checkpoint: {}".format(checkpoint.model_checkpoint_path))
        else:
            raise RuntimeError("Unable to load checkpoint")

        cv2.startWindowThread()
        cv2.namedWindow("preview")
        cv2.namedWindow("full")
开发者ID:amharc,项目名称:jnp3,代码行数:22,代码来源:visualize.py

示例11: __init__

 def __init__(self, 
             name="",
             client_id=None,
             client_secret=None,
             emulator=False,
             debug=True,
             template_folder='templates'):
     self.name = name
     self.emulator = emulator
     self.debug = debug
     self.web = flask.Flask(self.name,
         static_folder=os.path.join(os.path.dirname(os.path.abspath(__file__)), 'emulator'),
         static_url_path='/emulator')
     self.template_folder = template_folder
     self.logger = self.web.logger
     self.emulator_service = Emulator(app=self)
     self.subscriptions = Subscriptions(app=self)
     self.oauth = rauth.OAuth2Service(name=self.name,
                               client_id=client_id,
                               client_secret=client_secret,
                               access_token_url=self.OAUTH_ACCESS_TOKEN_URL,
                               authorize_url=self.OAUTH_AUTHORIZE_URL,
                               base_url=self.OAUTH_API_BASE_URL)
开发者ID:Valay,项目名称:glass.py,代码行数:23,代码来源:app.py

示例12: deque

        network.rewards: rewards
    }

    global summary_timer
    summary_timer += 1
    if timer > RECORD and summary_timer % SUMMARY_DELTA == 0:
        writer.add_summary(
            session.run(merged, feed_dict=feed_dict),
            timer
        )

    train_op.run(feed_dict=feed_dict)

if __name__ == '__main__':
    replay = deque([], maxlen=REPLAY_LEN)
    emulator = Emulator(rom='breakout.bin')

    session = tf.InteractiveSession()
    with tf.variable_scope("network"):
        network = Network(len(emulator.actions))

    global_step = tf.Variable(0, name='global_step', trainable=False)

    #optimizer  = tf.train.RMSPropOptimizer(0.0002, 0.99, 0.99, 1e-6)
    optimizer  = tf.train.AdamOptimizer(1e-5)
    grads_vars = optimizer.compute_gradients(network.cost)
    clipped    = [(tf.clip_by_norm(g, 5, name="clip_grads"), v) for (g, v) in grads_vars]
    for g, v in clipped:
        tf.histogram_summary("clipped_grad_" + v.name, g)
    train_op   = optimizer.apply_gradients(clipped, global_step=global_step, name="apply_grads")
    #optimizer = tf.train.AdamOptimizer(25e-5, epsilon=0.1).minimize(network.cost)
开发者ID:amharc,项目名称:jnp3,代码行数:31,代码来源:engine.py

示例13: Marionette

class Marionette(object):

    CONTEXT_CHROME = 'chrome'
    CONTEXT_CONTENT = 'content'
    TIMEOUT_SEARCH = 'implicit'
    TIMEOUT_SCRIPT = 'script'
    TIMEOUT_PAGE = 'page load'

    def __init__(self, host='localhost', port=2828, bin=None, profile=None,
                 emulator=None, sdcard=None, emulatorBinary=None,
                 emulatorImg=None, emulator_res='480x800', gecko_path=None,
                 connectToRunningEmulator=False, homedir=None, baseurl=None,
                 noWindow=False, logcat_dir=None, busybox=None):
        self.host = host
        self.port = self.local_port = port
        self.bin = bin
        self.instance = None
        self.profile = profile
        self.session = None
        self.window = None
        self.emulator = None
        self.extra_emulators = []
        self.homedir = homedir
        self.baseurl = baseurl
        self.noWindow = noWindow
        self.logcat_dir = logcat_dir
        self._test_name = None

        if bin:
            self.instance = GeckoInstance(host=self.host, port=self.port,
                                          bin=self.bin, profile=self.profile)
            self.instance.start()
            assert(self.wait_for_port())

        if emulator:
            self.emulator = Emulator(homedir=homedir,
                                     noWindow=self.noWindow,
                                     logcat_dir=self.logcat_dir,
                                     arch=emulator,
                                     sdcard=sdcard,
                                     emulatorBinary=emulatorBinary,
                                     userdata=emulatorImg,
                                     res=emulator_res)
            self.emulator.start()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        if connectToRunningEmulator:
            self.emulator = Emulator(homedir=homedir,
                                     logcat_dir=self.logcat_dir)
            self.emulator.connect()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port())

        self.client = MarionetteClient(self.host, self.port)

        if emulator:
            self.emulator.setup(self, gecko_path=gecko_path)
            if busybox:
                self.emulator.install_busybox(busybox)

    def __del__(self):
        if self.emulator:
            self.emulator.close()
        if self.instance:
            self.instance.close()
        for qemu in self.extra_emulators:
            qemu.emulator.close()

    @classmethod
    def getMarionetteOrExit(cls, *args, **kwargs):
        try:
            m = cls(*args, **kwargs)
            return m
        except InstallGeckoError:
            # Bug 812395 - the process of installing gecko into the emulator
            # and then restarting B2G tickles some bug in the emulator/b2g
            # that intermittently causes B2G to fail to restart.  To work
            # around this in TBPL runs, we will fail gracefully from this
            # error so that the mozharness script can try the run again.

            # This string will get caught by mozharness and will cause it
            # to retry the tests.
            print "Error installing gecko!"

            # Exit without a normal exception to prevent mozharness from
            # flagging the error.
            sys.exit()

    def wait_for_port(self, timeout=3000):
        starttime = datetime.datetime.now()
        while datetime.datetime.now() - starttime < datetime.timedelta(seconds=timeout):
            try:
                sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                sock.connect((self.host, self.port))
                data = sock.recv(16)
                sock.close()
                if '"from"' in data:
                    time.sleep(5)
                    return True
#.........这里部分代码省略.........
开发者ID:marcofreda527,项目名称:jb412gecko,代码行数:101,代码来源:marionette.py

示例14: Emulator

import sys
from nes import Controller
from screen import Screen
from fps import FPS
from tas import TAS
from emulator import Emulator

if __name__ == "__main__":
    parser = argparse.ArgumentParser(
            description = 'Dumps NES header information')
    parser.add_argument('pathname', help='specify the NES file to open')
    parser.add_argument('--tas', dest='tas', help='specify a TAS file to run', default=None)
    parser.add_argument('--scale', dest='scale', help='specify the screen scale', default = 1)
    args = parser.parse_args()

    emulator = Emulator(args.pathname)
    screen = Screen(args.scale)
    fps = FPS()
    if args.tas:
        target_fps = 1000.0
        tas = TAS(args.tas)
    else:
        target_fps = 60.0
        tas = None
    
    keep_going = True
    while keep_going:
        try:
            # Get button presses
            if tas == None:
                pressed = pygame.key.get_pressed()
开发者ID:LCClyde,项目名称:NyraEmulationSystem,代码行数:31,代码来源:run_emulator.py

示例15: Marionette

class Marionette(object):
    """
    Represents a Marionette connection to a browser or device.
    """

    CONTEXT_CHROME = 'chrome' # non-browser content: windows, dialogs, etc.
    CONTEXT_CONTENT = 'content' # browser content: iframes, divs, etc.
    TIMEOUT_SEARCH = 'implicit'
    TIMEOUT_SCRIPT = 'script'
    TIMEOUT_PAGE = 'page load'

    def __init__(self, host='localhost', port=2828, app=None, app_args=None, bin=None,
                 profile=None, emulator=None, sdcard=None, emulatorBinary=None,
                 emulatorImg=None, emulator_res=None, gecko_path=None,
                 connectToRunningEmulator=False, homedir=None, baseurl=None,
                 noWindow=False, logcat_dir=None, busybox=None, symbols_path=None,
                 timeout=None, device_serial=None):
        self.host = host
        self.port = self.local_port = port
        self.bin = bin
        self.instance = None
        self.profile = profile
        self.session = None
        self.window = None
        self.emulator = None
        self.extra_emulators = []
        self.homedir = homedir
        self.baseurl = baseurl
        self.noWindow = noWindow
        self.logcat_dir = logcat_dir
        self._test_name = None
        self.symbols_path = symbols_path
        self.timeout = timeout
        self.device_serial = device_serial

        if bin:
            port = int(self.port)
            if not Marionette.is_port_available(port, host=self.host):
                ex_msg = "%s:%d is unavailable." % (self.host, port)
                raise MarionetteException(message=ex_msg)
            if app:
                # select instance class for the given app
                try:
                    instance_class = geckoinstance.apps[app]
                except KeyError:
                    msg = 'Application "%s" unknown (should be one of %s)'
                    raise NotImplementedError(msg % (app, geckoinstance.apps.keys()))
            else:
                instance_class = geckoinstance.GeckoInstance
            self.instance = instance_class(host=self.host, port=self.port,
                                           bin=self.bin, profile=self.profile, app_args=app_args)
            self.instance.start()
            assert(self.wait_for_port()), "Timed out waiting for port!"

        if emulator:
            self.emulator = Emulator(homedir=homedir,
                                     noWindow=self.noWindow,
                                     logcat_dir=self.logcat_dir,
                                     arch=emulator,
                                     sdcard=sdcard,
                                     emulatorBinary=emulatorBinary,
                                     userdata=emulatorImg,
                                     res=emulator_res)
            self.emulator.start()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port()), "Timed out waiting for port!"

        if connectToRunningEmulator:
            self.emulator = Emulator(homedir=homedir,
                                     logcat_dir=self.logcat_dir)
            self.emulator.connect()
            self.port = self.emulator.setup_port_forwarding(self.port)
            assert(self.emulator.wait_for_port()), "Timed out waiting for port!"

        self.client = MarionetteClient(self.host, self.port)

        if emulator:
            self.emulator.setup(self,
                                gecko_path=gecko_path,
                                busybox=busybox)

    def __del__(self):
        if self.emulator:
            self.emulator.close()
        if self.instance:
            self.instance.close()
        for qemu in self.extra_emulators:
            qemu.emulator.close()

    @staticmethod
    def is_port_available(port, host=''):
        port = int(port)
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            s.bind((host, port))
            return True
        except socket.error:
            return False
        finally:
            s.close()
#.........这里部分代码省略.........
开发者ID:jonathanmarvens,项目名称:mozilla-central,代码行数:101,代码来源:marionette.py


注:本文中的emulator.Emulator类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。