Example #1
0
def OpenPro1():
    if mGui.Listname.get() != '':
        deckname = mGui.Listname.get()
    elif len(mGui.Listentry.get("1.0", "end-1c")) != 0:
        deckname = 'sample.txt'
        if os.path.isfile(deckname):
            os.remove(deckname)
        decktext = mGui.Listentry.get("1.0", 'end-1c')
        with open(deckname, "a") as outf:
            outf.write(decktext + '\n')

    builder.main(deckname)

    if deckname == 'sample.txt':
        if os.path.exists(os.path.join(globals.CACHE_PATH, deckname)):
            os.remove(os.path.join(globals.CACHE_PATH, deckname))

        os.rename(deckname, os.path.join(globals.CACHE_PATH, deckname))

    novi = Toplevel()
    canvas = Canvas(novi, width=350, height=1000)
    canvas.pack(expand=YES, fill=BOTH)
    #gif1 = PhotoImage(file = 'image.gif')
    gif1 = ImageTk.PhotoImage(Image.open(deckname[:-4] + '.png'))
    canvas.create_image(50, 10, image=gif1, anchor=NW)
    #assigned the gif1 to the canvas object
    canvas.gif1 = gif1

    mGui.btn2text.set('BannerIt ' + deckname[:-4])
    mGui.Button_2.config(state='active')
Example #2
0
def main():
    args = parse_options()

    if args.crawl or args.serve:
        import crawler
        crawler.main()

    if args.build or args.serve:
        import builder
        builder.main()
Example #3
0
 def on_modified(self, event):
     print(event.src_path)
     if islist(event):
         time.sleep(1)
         if os.path.exists(self.static_img):
             os.remove(self.static_img)
         try:
             res = builder.main(event.src_path)
             shutil.copyfile(res, self.static_img)
         except Exception as e:
             print(e)
Example #4
0
def main_redo_ifchange(redo_flavour, targets):
    import ifchange, state, vars, builder
    from log import debug2

    if vars.TARGET:
        f = state.File(name=vars.TARGET)
        debug2('TARGET: %r %r %r\n', vars.STARTDIR, vars.PWD, vars.TARGET)
    else:
        f = None
        debug2('%s: no target - not adding depends.\n', redo_flavour)

    targets = state.fix_chdir(targets)
    return builder.main(targets, ifchange.should_build, f, re_do=False)
Example #5
0
def main_redo_delegate(redo_flavour, targets):
    import builder, state, vars
    from log import debug2

    if vars.TARGET:
        f = state.File(name=vars.TARGET)
        debug2('TARGET: %r %r %r\n', vars.STARTDIR, vars.PWD, vars.TARGET)
    else:
        f = None
        debug2('%S: no target - not delegating.\n', redo_flavour)

    targets = state.fix_chdir(targets)
    return builder.main(targets, delegate=f)
Example #6
0
def auto_load():
    logging.basicConfig(filename=LOG_FILE, level=logging.INFO, filemode='w')
    
    logging.info('Started auto_load process.')
    start_time = time.time()
    while True:
        time.sleep(5)

        pid = None
        for proc in psutil.process_iter():
            if BIN_NAME in proc.name():
                pid = proc.pid
                logging.info('Watching process with pid {} and name "{}".'.format(pid, proc.name()))

        if pid is None:
            continue

        logging.info('Checking for modifications.')
        modified = False
        
        stages = ['../res/' + s for s in os.listdir('../res') if re.match(r'stage_.+', s)]
        for stage in stages:
            for path, _, files in os.walk(stage):
                for file in files:
                    name = os.path.join(path, file)
                    if '#' not in name and '~' not in name:
                        if os.stat(name).st_mtime >= start_time:
                            logging.info('{} was modified.'.format(name))
                            modified = True

        if modified:
            logging.info('Initiating a reload.')
            builder.main()
            os.kill(pid, signal.SIGUSR1)
            start_time = time.time()

        logging.info('Check complete.')
Example #7
0
    # only do this from the toplevel redo process, so unless the user
    # deliberately starts more than one redo on the same repository, it's
    # sort of ok.
    mkdirp('%s/.redo' % base)
    for f in glob.glob('%s/.redo/lock*' % base):
        os.unlink(f)


if not vars.DEPTH:
    # toplevel call to redo
    exenames = [os.path.abspath(sys.argv[0]), os.path.realpath(sys.argv[0])]
    if exenames[0] == exenames[1]:
        exenames = [exenames[0]]
    dirnames = [os.path.dirname(p) for p in exenames]
    os.environ['PATH'] = ':'.join(dirnames) + ':' + os.environ['PATH']

try:
    j = atoi.atoi(opt.jobs or 1)
    if j < 1 or j > 1000:
        err('invalid --jobs value: %r\n' % opt.jobs)
    jwack.setup(j)
    try:
        retcode = builder.main(targets, builder.build)
    finally:
        jwack.force_return_tokens()
    if retcode:
        err('exiting: %d\n' % retcode)
    sys.exit(retcode)
except KeyboardInterrupt:
    sys.exit(200)
Example #8
0
File: redo.py Project: tonyg/redo
            debug_locks=opt.debug_locks, debug_pids=opt.debug_pids)
    for t in targets:
        if os.path.exists(t):
            f = state.File(name=t)
            if not f.is_generated:
                warn('%s: exists and not marked as generated; not redoing.\n'
                     % f.nicename())
    state.rollback()
    
    j = atoi(opt.jobs or 1)
    if j < 1 or j > 1000:
        err('invalid --jobs value: %r\n' % opt.jobs)
    jwack.setup(j)
    try:
        assert(state.is_flushed())
        retcode = builder.main(targets, lambda t: (True, True))
        assert(state.is_flushed())
    finally:
        try:
            state.rollback()
        finally:
            try:
                jwack.force_return_tokens()
            except Exception, e:
                traceback.print_exc(100, sys.stderr)
                err('unexpected error: %r\n' % e)
                retcode = 1
    if vars_init.is_toplevel:
        builder.await_log_reader()
    sys.exit(retcode)
except KeyboardInterrupt:
Example #9
0
    f = state.File(name=t)
    if f.is_failed():
        raise builder.ImmediateReturn(32)
    dirty = deps.isdirty(f, depth = '', max_changed = vars.RUNID)
    return dirty==[f] and deps.DIRTY or dirty


rv = 202
try:
    if vars.TARGET and not vars.UNLOCKED:
        me = os.path.join(vars.STARTDIR, 
                          os.path.join(vars.PWD, vars.TARGET))
        f = state.File(name=me)
        debug2('TARGET: %r %r %r\n' % (vars.STARTDIR, vars.PWD, vars.TARGET))
    else:
        f = me = None
        debug2('redo-ifchange: not adding depends.\n')
    try:
        targets = sys.argv[1:]
        if f:
            for t in targets:
                f.add_dep('m', t)
            f.save()
        rv = builder.main(targets, should_build)
    finally:
        jwack.force_return_tokens()
except KeyboardInterrupt:
    sys.exit(200)
state.commit()
sys.exit(rv)
Example #10
0
def main_redo(redo_flavour, targets):
    import builder, state

    targets = state.fix_chdir(targets)
    return builder.main(targets)
Example #11
0
if opt.old_args:
    os.environ['REDO_OLD_ARGS'] = '1'
if opt.target_only:
    os.environ['REDO_TARGET_ONLY'] = '1'

import vars_init
vars_init.init(targets)

import vars, state, builder, jwack
from log import warn, err

try:
    for t in targets:
        if os.path.exists(t):
            f = state.File(name=t)
            if not f.is_generated:
                warn('%s: exists and not marked as generated; not redoing.\n'
                     % f.nicename())
    
    j = atoi(opt.jobs or 1)
    if j < 1 or j > 1000:
        err('invalid --jobs value: %r\n' % opt.jobs)
    jwack.setup(j)
    try:
        retcode = builder.main(targets, lambda t: True)
    finally:
        jwack.force_return_tokens()
    sys.exit(retcode)
except KeyboardInterrupt:
    sys.exit(200)
Example #12
0

def dirty_deps(t, depth, fromdir=None):
    if _dirty_deps(t, depth, fromdir):
        state.unstamp(t, fromdir)
        return True
    return False


def maybe_build(t):
    if dirty_deps(t, depth = ''):
        builder.build(t)


if not vars.TARGET:
    err('redo-ifchange: error: must be run from inside a .do\n')
    sys.exit(100)

rv = 202
try:
    want_build = []
    for t in sys.argv[1:]:
        state.add_dep(vars.TARGET, 'm', t)
        if dirty_deps(t, depth = ''):
            want_build.append(t)

    rv = builder.main(want_build, maybe_build)
except KeyboardInterrupt:
    sys.exit(200)
sys.exit(rv)
Example #13
0
if opt.debug_pids:
    os.environ['REDO_DEBUG_PIDS'] = '1'
if opt.old_args:
    os.environ['REDO_OLD_ARGS'] = '1'

import vars_init
vars_init.init(targets)

import vars, state, builder, jwack, deps
from log import warn, err

try:
    for t in targets:
        if os.path.exists(t):
            f = state.File(name=t)
            if not f.is_generated:
                warn('%s: exists and not marked as generated; not redoing.\n'
                     % f.nicename())
    
    j = atoi(opt.jobs or 1)
    if j < 1 or j > 1000:
        err('invalid --jobs value: %r\n' % opt.jobs)
    jwack.setup(j)
    try:
        retcode = builder.main(targets, lambda t: deps.DIRTY_forced)
    finally:
        jwack.force_return_tokens()
    sys.exit(retcode)
except KeyboardInterrupt:
    sys.exit(200)