def dispatch(args): "run the command specified in args" try: u = _ui.ui(traceback='--traceback' in args) except util.Abort, inst: sys.stderr.write(_("abort: %s\n") % inst) return -1
def dispatch(req): "run the command specified in req.args" if req.ferr: ferr = req.ferr elif req.ui: ferr = req.ui.ferr else: ferr = sys.stderr try: if not req.ui: req.ui = uimod.ui() if '--traceback' in req.args: req.ui.setconfig('ui', 'traceback', 'on') # set ui streams from the request if req.fin: req.ui.fin = req.fin if req.fout: req.ui.fout = req.fout if req.ferr: req.ui.ferr = req.ferr except util.Abort, inst: ferr.write(_("abort: %s\n") % inst) if inst.hint: ferr.write(_("(%s)\n") % inst.hint) return -1
def __init__(self,configFileName='config.txt'): self.ui = ui.ui() try: self.ui.run() except: self.ui.textMode = True self.ui.run() signal.signal(signal.SIGINT, self.ui.close) self.isRunnable = False self.config = configparser.ConfigParser() self.configFileName = configFileName if os.path.isfile(self.configFileName) == False: self.setup() else: try: self.config.read(self.configFileName) if os.path.isdir(self.config['Folder Settings']['unsortedfolder']) == False: os.mkdir(self.config['Folder Settings']['unsortedfolder']) if len(self.config['API Settings']['apikey']) == 32 and self.config['API Settings']['apikey'] != '' and self.config['API Settings']['apikey'] != '[Enter your TMDB API Key here]': self.isRunnable = True self.tvdbsearch = tvdb.Tvdb(language=self.config['API Settings']['language']) else: self.ui.informationDialog('API Key','You need a TMDB API Key to use this programm. You can enter the key in the file {}.'.format(self.configFileName)) except KeyError: self.setup() except configparser.ParsingError: self.setup()
def __init__(self): '''Handler Initialisations. Obtain all references here.''' self.builder = Gtk.Builder() self.glade="mechanig.glade" # TODO : Use os module to resolve to the full path. self.builder.add_from_file(self.glade) self.ui=ui(self.builder) # GSettings objects go here self.unityshell=self.plugin('unityshell') self.desktop=self.gnome('nautilus.desktop') self.background=self.gnome('desktop.background') self.launcher=self.unity('Launcher') self.power=self.canonical('indicator.power') # Fire the engines # The UI must be refreshed before connecting signals. # Else all handlers get called when setting initial values and may cause a mess. self.refresh() self.builder.connect_signals(self) self.ui['mechanig_main'].set_resizable(False) self.ui['nb_mechanig'].set_show_tabs(False) self.ui['mechanig_main'].connect("delete-event", Gtk.main_quit) self.ui['mechanig_main'].show_all() Gtk.main()
def __init__(self, container): '''Handler Initialisations. Obtain all references here.''' self.builder = Gtk.Builder() self.glade = 'compiz.ui' self.container = container # TODO : Use os module to resolve to the full path. self.builder.add_from_file(self.glade) self.ui = ui(self.builder) self.page = self.ui['nb_compizsettings'] self.page.unparent() # GSettings objects go here self.unityshell=self.plugin('unityshell') self.desktop=self.gnome('nautilus.desktop') self.background=self.gnome('desktop.background') self.launcher=self.unity('Launcher') self.opengl=self.plugin('opengl') self.core=self.plugin('core') self.scale=self.plugin('scale') self.expo=self.plugin('expo') self.move=self.plugin('move') self.zoom=self.plugin('ezoom') self.builder.connect_signals(self) self.refresh()
def __init__(self): '''Handler Initialisations. Obtain all references here.''' self.builder = Gtk.Builder() self.glade = "mechanig.ui" # TODO : Use os module to resolve to the full path. self.builder.add_from_file(self.glade) self.ui = ui(self.builder) self.builder.connect_signals(self) self.ui['mechanig_main'].set_resizable(False) #self.ui['nb_mechanig'].set_show_tabs(False) self.notebook = self.ui['nb_mechanig'] self.startpage = Startpage(self.ui, self.notebook) self.unitysettings = Unitysettings(self.ui) self.compizsettings = Compizsettings(self.ui) self.themesettings = Themesettings(self.ui) self.desktopsettings = Desktopsettings(self.ui) #self.box.pack_end(self.start, True, True, 0) self.notebook.append_page(self.startpage.page, None) self.notebook.append_page(self.unitysettings.page, None) self.notebook.append_page(self.compizsettings.page, None) self.notebook.append_page(self.themesettings.page, None) self.notebook.append_page(self.desktopsettings.page, None) self.ui['mechanig_main'].show_all() self.ui['mechanig_main'].connect("delete-event", Gtk.main_quit) Gtk.main()
def __init__(self, container): '''Handler Initialisations. Obtain all references here.''' self.builder = Gtk.Builder() self.glade = 'unity.ui' self.container = container # TODO : Use os module to resolve to the full path. self.builder.add_from_file(self.glade) self.ui = ui(self.builder) self.page = self.ui['nb_unitysettings'] self.page.unparent() self.builder.connect_signals(self) # TODO : Set these marks to the proper "sticky" location revealScale = self.ui['sc_reveal_sensitivity'] revealScale.add_mark(5.333, Gtk.PositionType.BOTTOM, None) transparencyScale = self.ui['sc_launcher_transparency'] transparencyScale.add_mark(.666, Gtk.PositionType.BOTTOM, None) # GSettings objects go here self.unityshell=self.plugin('unityshell') self.desktop=self.gnome('nautilus.desktop') self.background=self.gnome('desktop.background') self.launcher=self.unity('Launcher') self.power=self.canonical('indicator.power') self.session=self.canonical('indicator.session') self.refresh()
def dispatch(args): "run the command specified in args" try: u = _ui.ui() if '--traceback' in args: u.setconfig('ui', 'traceback', 'on') except util.Abort, inst: sys.stderr.write(_("abort: %s\n") % inst) return -1
def _libInit (self): try: # Initialize the main plugin engine self.plug = plug (self) self.update = update (self) self.ui = ui (self) self.support = support (self) self.logger.threaddebug("Dynamic libraries complete") except Exception as e: self.logger.error (ext.getException(e))
def __init__(self): self.builder=Gtk.Builder() self.glade="waterloo.glade" self.builder.add_from_file(self.glade) self.ui=ui(self.builder) self.builder.connect_signals(self) self.ui['waterloo_main'].set_resizable(False) self.ui['waterloo_main'].show_all() self.ui['waterloo_main'].connect("delete-event", Gtk.main_quit) Gtk.main()
def __init__(self, container, notebook): '''Handler Initialisations. Obtain all references here.''' self.builder = Gtk.Builder() self.container = container self.notebook = notebook #self.page = 'box_startpage' # TODO : Use os module to resolve to the full path. #self.builder.add_objects_from_file('startpage.ui', [self.page]) self.builder.add_from_file('startpage.ui') self.ui = ui(self.builder) self.page = self.ui['box_startpage'] self.page.unparent() self.builder.connect_signals(self)
def __init__(self, container): '''Handler Initialisations. Obtain all references here.''' self.builder = Gtk.Builder() self.glade = 'theme.ui' self.container = container # TODO : Use os module to resolve to the full path. self.builder.add_from_file(self.glade) self.ui = ui(self.builder) self.page = self.ui['nb_themesettings'] self.page.unparent() self.builder.connect_signals(self) # GSettings objects go here self.font=self.gnome('desktop.interface') self.titlefont=self.gnome('desktop.wm.preferences') self.antialiasing=self.gnome('settings-daemon.plugins.xsettings') self.builder.connect_signals(self) self.refresh()
def __init__(self, container): '''Handler Initialisations. Obtain all references here.''' self.builder = Gtk.Builder() self.glade = 'desktop.ui' self.container = container # TODO : Use os module to resolve to the full path. self.builder.add_from_file(self.glade) self.ui = ui(self.builder) self.page = self.ui['box_desktop_settings'] self.page.unparent() # GSettings objects go here self.unityshell=self.plugin('unityshell') self.desktop=self.gnome('nautilus.desktop') self.background=self.gnome('desktop.background') self.launcher=self.unity('Launcher') self.power=self.canonical('indicator.power') self.builder.connect_signals(self) self.refresh()
def on_key(self, key): ui().on_key(key)
from pumpbody import Pump as Body from menuFSM import MenuFSM from button import * from ui import UI as ui pygame.init() Pump = Body(500, 150, .45) UI = ui(150, 900, scale=.25) # Set up the drawing window #screen = pygame.display.set_mode([800, 600]) screen = pygame.display.set_mode((0, 0), pygame.FULLSCREEN) MenuHandler = MenuFSM(Pump, UI, screen) # Run until the user asks to quit running = True while running: # Did the user click the window close button? for event in pygame.event.get(): if event.type == pygame.QUIT: running = False if event.type == pygame.KEYDOWN: pressed = pygame.key.get_pressed() if pressed[pygame.K_q]: running = False if event.type == pygame.MOUSEBUTTONDOWN: for index, btn in enumerate(Pump.Buttons): if btn.isClicked():
def admin(path, **kwargs): return ui.ui(os.path.join('admin', path), require_admin=True, **kwargs)
from ui import ui # from person import person # 필요가 없어! main입장에서는 person을 알 필요가 없지 ui = ui() ui.run()
if not database.insert_stats(DB_NAME, USER, HOST, PASSWORD, TABLE, temperature, humidity): self.running = False return # update time of last attempted write last_write = time.time() # sleep for amount of time to wait between reads time.sleep(READ_INTERVAL) return if __name__ == '__main__': automation_inst = automation() ui_inst = ui.ui(automation_inst) # create threads for ui and database threads = [] threads.append(threading.Thread(name='automation', target=automation_inst.run)) threads.append(threading.Thread(name='ui', target=ui_inst.run)) for thread in threads: thread.start() for thread in threads: thread.join()
def run_game(self): # Game parameters self.SCREEN_WIDTH = conf.SCREEN_WIDTH self.SCREEN_HEIGHT = conf.SCREEN_HEIGHT BG_COLOR = conf.BG_COLOR self.BLOCKSIZE = conf.BLOCKSIZE self.SNACKS = conf.SNACKS self.gameSpeed = 250 self.gameSpeedFactors = range(0, 400, 25) self.gameSpeedFactor = 0 pygame.init() self.REST_WITH = self.SCREEN_WIDTH % self.BLOCKSIZE self.REST_HEIGHT = self.SCREEN_HEIGHT % self.BLOCKSIZE self.DRAW_RECT = pygame.Rect(0, 0, self.SCREEN_WIDTH - self.REST_WITH, self.SCREEN_HEIGHT - self.REST_HEIGHT) # do fancy window stuff pygame.display.set_caption("pySnake") #pygame.display.set_icon(pygame.image.load('imgs/bandit.jpg')) pygame.mouse.set_visible(False) if not conf.FULLSCREEN: os.environ['SDL_VIDEO_WINDOW_POS'] = "%d,%d" % (conf.WINDOW_POSITION_X, conf.WINDOW_POSITION_Y) if not conf.WINDOW_BORDER: self.screen = pygame.display.set_mode((self.SCREEN_WIDTH, self.SCREEN_HEIGHT), pygame.NOFRAME, 32) if self.screen is None: self.screen = pygame.display.set_mode((self.SCREEN_WIDTH, self.SCREEN_HEIGHT), 0, 32) if conf.FULLSCREEN: pygame.display.toggle_fullscreen() clock = pygame.time.Clock() redrawCount = 0 # init the menu, add stuff later self.iUi = ui(self.screen) self.popUp = popUp(self.screen) self.popUp.color = conf.FONT_COLOR self.touchScreen = touchScreen(self.SCREEN_WIDTH, self.SCREEN_HEIGHT) pygame.joystick.init() self.joystickInteract = joystick() keymap = {pygame.K_UP: 1, pygame.K_RIGHT: 2, pygame.K_DOWN: 3, pygame.K_LEFT: 4} self.playerBox = None self.elements = [] self.haveToAdd = [] # The main game loop # gameOver = False doMove = -1 while True: if self.playerBox is None: self.resetGame() # Limit frame speed to 50 FPS # time_passed = clock.tick(50) redrawCount += time_passed if self.joystickInteract.joystickAvailable(): joyAction = self.joystickInteract.getAction() if joyAction == "move": doMove = self.joystickInteract.getMoveAction() elif joyAction == "speedUp": self.gameSpeedUp() elif joyAction == "speedDown": self.gameSpeedDown() elif joyAction == "restart": self.resetGame() gameOver = False elif joyAction == 'quit': self.exit_game() for event in pygame.event.get(): if event.type == pygame.QUIT: self.exit_game() elif event.type == pygame.KEYDOWN: if event.key in keymap: doMove = keymap[event.key] elif event.key == pygame.K_2: # speed up game self.gameSpeedUp() elif event.key == pygame.K_1: # slow down up game self.gameSpeedDown() elif event.key == pygame.K_r: # restart game self.resetGame() gameOver = False elif event.key == pygame.K_q: self.exit_game() else: print "event.key:", event.key #if event.key == pygame.K_UP: # self.move(1) else: pass #print event if conf.TOUCH_SCREEN: mouseAction = self.touchScreen.getEventBoxes() if mouseAction > 0: if gameOver: self.resetGame() gameOver = False else: doMove = mouseAction if gameOver is False and redrawCount >= (self.gameSpeed - self.gameSpeedFactors[self.gameSpeedFactor]): # ONLY move, when the timer elapses! # otherwise you could change the direction multiple times before the scenery changes and upates # strange shit goes on! if doMove != -1: self.move(doMove) doMove = -1 redrawCount = 0 self.screen.fill(BG_COLOR, self.DRAW_RECT) # move the elements for elem in reversed(self.elements): elem.update() # add elements BEFORE blit is called and they change direction! # WEIRD stuff would happen otherwise!!!1!!!!!!!! if len(self.haveToAdd) > 0: for i in range(len(self.haveToAdd)): coords = self.haveToAdd[i] if self.fieldContainsBox(self.elements, coords[0], coords[1]) is False: lastElem = self.getLastElement() lastElem.back = box(self.screen, self.BLOCKSIZE, coords[0], coords[1]) lastElem.back.setDirection(lastElem.getDirection()) self.elements.append(self.getLastElement()) self.haveToAdd.pop(i) break else: # if there is NOTHING to add to the Snake, add a new snak, if needed # preventing from spawning a snack inside the "new" tail of the snake and shit self.addSnack(self.elements) # update elements for elem in reversed(self.elements): elem.blit() # draw touchscreen # TODO: draw touch areas # draw pop ups self.popUp.drawPopUps() # if a snack has been eaten, add it to the to add list snackEaten = self.eatSnack(self.elements) if snackEaten is not None: self.haveToAdd.append(snackEaten) self.popUp.singlePopUp(str(self.getBodyLen())) # collision! if self.headDied(self.elements): gameOver = True pygame.display.flip()
#!/usr/bin/env python import cgi from ui import ui u = ui() u.mainpg()
def __init__(self, number): self.l = [] for i in range(number): self.l.append(ui(5 + 10 * i, 5, 5, 5, self.red())) self.txt = "oi"
def _dispatch(ui, args): # read --config before doing anything else # (e.g. to change trust settings for reading .hg/hgrc) config = _earlygetopt(['--config'], args) if config: ui.updateopts(config=_parseconfig(config)) # check for cwd cwd = _earlygetopt(['--cwd'], args) if cwd: os.chdir(cwd[-1]) # read the local repository .hgrc into a local ui object path = _findrepo(os.getcwd()) or "" if not path: lui = ui if path: try: lui = _ui.ui(parentui=ui) lui.readconfig(os.path.join(path, ".hg", "hgrc")) except IOError: pass # now we can expand paths, even ones in .hg/hgrc rpath = _earlygetopt(["-R", "--repository", "--repo"], args) if rpath: path = lui.expandpath(rpath[-1]) lui = _ui.ui(parentui=ui) lui.readconfig(os.path.join(path, ".hg", "hgrc")) extensions.loadall(lui) for name, module in extensions.extensions(): if name in _loaded: continue # setup extensions # TODO this should be generalized to scheme, where extensions can # redepend on other extensions. then we should toposort them, and # do initialization in correct order extsetup = getattr(module, 'extsetup', None) if extsetup: extsetup() cmdtable = getattr(module, 'cmdtable', {}) overrides = [cmd for cmd in cmdtable if cmd in commands.table] if overrides: ui.warn(_("extension '%s' overrides commands: %s\n") % (name, " ".join(overrides))) commands.table.update(cmdtable) _loaded[name] = 1 # check for fallback encoding fallback = lui.config('ui', 'fallbackencoding') if fallback: util._fallbackencoding = fallback fullargs = args cmd, func, args, options, cmdoptions = _parse(lui, args) if options["config"]: raise util.Abort(_("Option --config may not be abbreviated!")) if options["cwd"]: raise util.Abort(_("Option --cwd may not be abbreviated!")) if options["repository"]: raise util.Abort(_( "Option -R has to be separated from other options (i.e. not -qR) " "and --repository may only be abbreviated as --repo!")) if options["encoding"]: util._encoding = options["encoding"] if options["encodingmode"]: util._encodingmode = options["encodingmode"] if options["time"]: def get_times(): t = os.times() if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() t = (t[0], t[1], t[2], t[3], time.clock()) return t s = get_times() def print_time(): t = get_times() ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) atexit.register(print_time) ui.updateopts(options["verbose"], options["debug"], options["quiet"], not options["noninteractive"], options["traceback"]) if options['help']: return commands.help_(ui, cmd, options['version']) elif options['version']: return commands.version_(ui) elif not cmd: return commands.help_(ui, 'shortlist') repo = None if cmd not in commands.norepo.split(): try: repo = hg.repository(ui, path=path) ui = repo.ui if not repo.local(): raise util.Abort(_("repository '%s' is not local") % path) ui.setconfig("bundle", "mainreporoot", repo.root) except RepoError: if cmd not in commands.optionalrepo.split(): if args and not path: # try to infer -R from command args repos = map(_findrepo, args) guess = repos[0] if guess and repos.count(guess) == len(repos): return _dispatch(ui, ['--repository', guess] + fullargs) if not path: raise RepoError(_("There is no Mercurial repository here" " (.hg not found)")) raise d = lambda: func(ui, repo, *args, **cmdoptions) else: d = lambda: func(ui, *args, **cmdoptions) # run pre-hook, and abort if it fails ret = hook.hook(lui, repo, "pre-%s" % cmd, False, args=" ".join(fullargs)) if ret: return ret ret = _runcommand(ui, options, cmd, d) # run post-hook, passing command result hook.hook(lui, repo, "post-%s" % cmd, False, args=" ".join(fullargs), result = ret) return ret
# Autogenerated, do not edit. All changes will be undone. from ui import ui ui() # go to ai.py,ffr.py or ui.py for actual code #WARNING TRAINDATA.CSV IS HUGE MAY LAG ON SLOW COMPUTERS # change testdata.csv to your datapoints
''' Created on Dec 7, 2015 @author: aflorea ''' from ui.ui import * from repository.repository import * from controller.controller import * aRepository = Repository() aController = Controller(aRepository) aUI = ui(aController) aUI.mainMenu()
#!/usr/bin/env python import cgi import ui from DBSearch import DBSearch x = DBSearch('foo','col') form = cgi.FieldStorage() reply = form.getvalue("search") y = x.search(reply) cnt = y.count() u = ui.ui() if cnt is not 0: u.results(y,cnt) else: u.notfound()
def main(): os.system('clear') UI = ui()
# get message text message = message.get('Body') print(message) self.sqs.delete_message(QueueUrl=self.q_url[my_queue], ReceiptHandle=receipt_handle) ## sends current log def send_message(self, address, message): self.sqs.send_message(QueueUrl=self.q_url[address], MessageBody=message) if __name__ == '__main__': # if given input, set as id if len(sys.argv) > 1 and sys.argv[1] != 'clear': server = Server(sys.argv[1]) ui = ui.ui(server) # grab that simulate flag if it exits if len(sys.argv) > 2: server.simulate = True # create list of threads threads_L = [] # create thread for polling threads_L.append(threading.Thread(name='poll', target=server.poll_queue)) threads_L.append(threading.Thread(name='ui', target=ui.run)) # start threads for thread in threads_L: thread.start()
import ui if __name__ == '__main__': window = ui.tk.Tk() root = ui.ui(master=window) root.mainloop()
import zipfile as zp import os from ui import ui import io from timeit import default_timer as timer # debug import sys #test start = timer() # debug x = ui() zipname = x[0] direc = x[1] def unzip(): try: os.chdir(direc) except IOError: print("Error: could not change directory") else: try: zp.is_zipfile(zipname) except zp.BadZipfile: print("File is not zip") else: with zp.ZipFile(zipname, 'r') as zf: zf.extractall('extract') try: os.chdir('extract')
# create new calendar passing all arguments after self cal = Calendar() threads_L = [] # if input arguments are given, run demo if len(sys.argv) > 1 and sys.argv[1] == '-l': cal = Calendar(new_session=False) print("Loaded log:") cal.print_log() print("Loaded calendar:") cal.print_calendar() elif len(sys.argv) > 1: cal = Calendar(my_id=int(sys.argv[1])) # create ui ui = UI.ui(cal) threads_L.append(threading.Thread(name='poll', target=cal.poll_queue)) threads_L.append(threading.Thread(name='ui', target=ui.run)) else: # create ui ui = UI.ui(cal) threads_L.append(threading.Thread(name='poll', target=cal.poll_queue)) threads_L.append(threading.Thread(name='ui', target=ui.run)) # start threads for thread in threads_L: thread.start() # join threads for thread in threads_L: thread.join()
def main(): parser = argparse.ArgumentParser() parser.add_argument('--verbose', type=bool, default=False) parser.add_argument('--node', action='append', default=[], help='Cilium pod names. Can specify multiple.') parser.add_argument('--selector', action='append', default=[], help='k8s equality label selectors for pods which ' 'monitor should listen to. each selector will ' 'retrieve its own set of pods. ' 'Format is "label-name=label-value" ' 'Can specify multiple.') parser.add_argument('--pod', action='append', default=[], help='pod names in form of "namespace:pod-name", ' 'if there is no namespace, default is assumed. ' 'Can specify multiple.') parser.add_argument('--endpoint', action='append', type=int, default=[], help='Cilium endpoint ids. Can specify multiple.') parser.add_argument('--to-selector', action='append', default=[], help='k8s equality label selectors for pods which ' 'monitor should listen to. each selector will ' 'retrieve its own set of pods. ' 'Matches events that go to selected pods. ' 'Format is "label-name=label-value" ' 'Can specify multiple.') parser.add_argument('--to-pod', action='append', default=[], help='pod names in form of "namespace:pod-name", ' 'if there is no namespace, default is assumed. ' 'Matches events that go to specified pods. ' 'Can specify multiple.') parser.add_argument('--to-endpoint', action='append', type=int, default=[], help='Cilium endpoint ids. ' 'Matches events that go to specified endpoints. ' 'Can specify multiple.') parser.add_argument('--from-selector', action='append', default=[], help='k8s equality label selectors for pods which ' 'monitor should listen to. each selector will ' 'retrieve its own set of pods. ' 'Matches events that come from selected pods. ' 'Format is "label-name=label-value" ' 'Can specify multiple.') parser.add_argument('--from-pod', action='append', default=[], help='pod names in form of "namespace:pod-name", ' 'if there is no namespace, default is assumed. ' 'Matches events that come from specified pods. ' 'Can specify multiple.') parser.add_argument('--from-endpoint', action='append', type=int, default=[], help='Cilium endpoint ids. ' 'Matches events that come from specified endpoints. ' 'Can specify multiple.') args = parser.parse_args() try: config.load_kube_config() except FileNotFoundError: config.load_incluster_config() c = Configuration() c.assert_hostname = False Configuration.set_default(c) api = core_v1_api.CoreV1Api() runner = MonitorRunner('kube-system', api) monitor_args = MonitorArgs(args.verbose, args.selector, args.pod, args.endpoint, args.to_selector, args.to_pod, args.to_endpoint, args.from_selector, args.from_pod, args.from_endpoint) try: runner.run(monitor_args, args.node) ui(runner) except KeyboardInterrupt as e: pass finally: runner.finish()
def _dispatch(ui, args): # read --config before doing anything else # (e.g. to change trust settings for reading .hg/hgrc) config = _earlygetopt(['--config'], args) if config: ui.updateopts(config=_parseconfig(config)) # check for cwd cwd = _earlygetopt(['--cwd'], args) if cwd: os.chdir(cwd[-1]) # read the local repository .hgrc into a local ui object path = _findrepo(os.getcwd()) or "" if not path: lui = ui if path: try: lui = _ui.ui(parentui=ui) lui.readconfig(os.path.join(path, ".hg", "hgrc")) except IOError: pass # now we can expand paths, even ones in .hg/hgrc rpath = _earlygetopt(["-R", "--repository", "--repo"], args) if rpath: path = lui.expandpath(rpath[-1]) lui = _ui.ui(parentui=ui) lui.readconfig(os.path.join(path, ".hg", "hgrc")) extensions.loadall(lui) for name, module in extensions.extensions(): if name in _loaded: continue # setup extensions # TODO this should be generalized to scheme, where extensions can # redepend on other extensions. then we should toposort them, and # do initialization in correct order extsetup = getattr(module, 'extsetup', None) if extsetup: extsetup() cmdtable = getattr(module, 'cmdtable', {}) overrides = [cmd for cmd in cmdtable if cmd in commands.table] if overrides: ui.warn(_("extension '%s' overrides commands: %s\n") % (name, " ".join(overrides))) commands.table.update(cmdtable) _loaded[name] = 1 # check for fallback encoding fallback = lui.config('ui', 'fallbackencoding') if fallback: util._fallbackencoding = fallback fullargs = args cmd, func, args, options, cmdoptions = _parse(lui, args) if options["config"]: raise util.Abort(_("Option --config may not be abbreviated!")) if options["cwd"]: raise util.Abort(_("Option --cwd may not be abbreviated!")) if options["repository"]: raise util.Abort(_( "Option -R has to be separated from other options (i.e. not -qR) " "and --repository may only be abbreviated as --repo!")) if options["encoding"]: util._encoding = options["encoding"] if options["encodingmode"]: util._encodingmode = options["encodingmode"] if options["time"]: def get_times(): t = os.times() if t[4] == 0.0: # Windows leaves this as zero, so use time.clock() t = (t[0], t[1], t[2], t[3], time.clock()) return t s = get_times() def print_time(): t = get_times() ui.warn(_("Time: real %.3f secs (user %.3f+%.3f sys %.3f+%.3f)\n") % (t[4]-s[4], t[0]-s[0], t[2]-s[2], t[1]-s[1], t[3]-s[3])) atexit.register(print_time) ui.updateopts(options["verbose"], options["debug"], options["quiet"], not options["noninteractive"], options["traceback"]) if options['help']: return commands.help_(ui, cmd, options['version']) elif options['version']: return commands.version_(ui) elif not cmd: return commands.help_(ui, 'shortlist') repo = None if cmd not in commands.norepo.split(): try: repo = hg.repository(ui, path=path) ui = repo.ui if not repo.local(): raise util.Abort(_("repository '%s' is not local") % path) ui.setconfig("bundle", "mainreporoot", repo.root) except error.RepoError: if cmd not in commands.optionalrepo.split(): if args and not path: # try to infer -R from command args repos = map(_findrepo, args) guess = repos[0] if guess and repos.count(guess) == len(repos): return _dispatch(ui, ['--repository', guess] + fullargs) if not path: raise error.RepoError(_("There is no Mercurial repository" " here (.hg not found)")) raise args.insert(0, repo) elif rpath: ui.warn("warning: --repository ignored\n") d = lambda: util.checksignature(func)(ui, *args, **cmdoptions) return runcommand(lui, repo, cmd, fullargs, ui, options, d)
def __init__(self, path, player): self.player = player self.path = path self.enemylist = [self.player, ui.ui(self.player)] self.loadMapFromFile(self.path)