Exemple #1
0
    def test_find_files(self):
        # find all files
        flist = find_files(self.tempdir)
        self.assertEqual(
            set([os.path.basename(f) for f in flist]),
            set([
                'd1d1f1.exe', 'd1d2f2', '_d2d1f1.foo', '_d2d2f1.txt',
                'd2d4d1f1.blah'
            ]))

        # find all .exe files
        flist = find_files(self.tempdir, '*.exe')
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d1f1.exe']))

        # find exe files or files starting with an underscore
        matcher = lambda name: fnmatch(name, '*.exe') or name.startswith('_')
        flist = find_files(self.tempdir, matcher)
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set([
                             'd1d1f1.exe',
                             '_d2d1f1.foo',
                             '_d2d2f1.txt',
                         ]))

        # find all files except .exe files
        flist = find_files(self.tempdir, exclude='*.exe')
        self.assertEqual(
            set([os.path.basename(f) for f in flist]),
            set(['d1d2f2', '_d2d1f1.foo', '_d2d2f1.txt', 'd2d4d1f1.blah']))

        # find all files except .exe files and files starting with '_'
        flist = find_files(self.tempdir, exclude=matcher)
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d2f2', 'd2d4d1f1.blah']))

        # only match .exe but exclude .exe and starting with '_', which results in no matches
        flist = find_files(self.tempdir, match='*.exe', exclude=matcher)
        self.assertEqual(set([os.path.basename(f) for f in flist]), set([]))

        # find all files except those under directories staring with '_'
        flist = find_files(self.tempdir, direxclude='_*')
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d1f1.exe', 'd1d2f2']))
Exemple #2
0
    def test_find_files(self):
        # find all files
        flist = find_files(self.tempdir)
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d1f1.exe', 'd1d2f2', '_d2d1f1.foo',
                              '_d2d2f1.txt', 'd2d4d1f1.blah']))

        # find all .exe files
        flist = find_files(self.tempdir, '*.exe')
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d1f1.exe']))

        # find exe files or files starting with an underscore
        matcher = lambda name: fnmatch(name, '*.exe') or name.startswith('_')
        flist = find_files(self.tempdir, matcher)
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d1f1.exe', '_d2d1f1.foo', '_d2d2f1.txt', ]))

        # find all files except .exe files
        flist = find_files(self.tempdir, exclude='*.exe')
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d2f2', '_d2d1f1.foo', '_d2d2f1.txt', 'd2d4d1f1.blah']))

        # find all files except .exe files and files starting with '_'
        flist = find_files(self.tempdir, exclude=matcher)
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d2f2', 'd2d4d1f1.blah']))

        # only match .exe but exclude .exe and starting with '_', which results in no matches
        flist = find_files(self.tempdir, match='*.exe', exclude=matcher)
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set([]))

        # find all files except those under directories staring with '_'
        flist = find_files(self.tempdir, direxclude='_*')
        self.assertEqual(set([os.path.basename(f) for f in flist]),
                         set(['d1d1f1.exe', 'd1d2f2']))
Exemple #3
0
def run_wing():
    """Runs the Wing IDE using our template project file."""
    parser = OptionParser()
    parser.add_option("-w", "--wingpath", action="store", type="string",
                      dest="wingpath", help="location of WingIDE executable")
    parser.add_option("-p", "--projpath", action="store", type="string",
                      dest="projpath", default='',
                      help="location of WingIDE project file")
    parser.add_option("-v", "--version", action="store", type="string",
                      dest="version", default='5.0',
                      help="version of WingIDE")
    (options, args) = parser.parse_args(sys.argv[1:])

    wingpath = options.wingpath
    projpath = options.projpath
    version = options.version
    if len(version)==1:
        version = version + '.0'

    if not os.path.isfile(projpath):

        # Support different versions of Wing
        major_rev = int(version.split('.')[0])
        if major_rev > 4:
            wingproj_file = 'wing_proj_template5.wpr'
        else:
            wingproj_file = 'wing_proj_template.wpr'

        mydir = os.path.dirname(os.path.abspath(__file__))
        proj_template = os.path.join(mydir,
                                     '../config', wingproj_file)
        projpath = os.path.join(mydir, '../config', 'wingproj.wpr')

        _modify_wpr_file(proj_template, projpath, version)

    # in order to find all of our shared libraries,
    # put their directories in LD_LIBRARY_PATH
    env = {}
    env.update(os.environ)
    if sys.platform == 'darwin':
        libpname = 'DYLD_LIBRARY_PATH'
        libext = '*.dyld'
    elif not sys.platform.startswith('win'):
        libpname = 'LD_LIBRARY_PATH'
        libext = '*.so'
    else:
        libpname = None

    if libpname:
        libs = env.get(libpname,'').split(os.pathsep)
        rtop = find_up('.git')
        if not rtop:
            rtop = find_up('.git')
        if rtop:
            rtop = os.path.dirname(rtop)
            sodirs = set([os.path.dirname(x) for x in find_files(rtop, libext)])
            libs.extend(sodirs)
            env[libpname] = os.pathsep.join(libs)

    if sys.platform == 'darwin':
        cmd = ['open', projpath]
    else:
        if not wingpath:
            wingpath = _find_wing()
        cmd = [wingpath, projpath]
    try:
        print("wing command: ",' '.join(cmd))
        Popen(cmd, env=env)
    except Exception as err:
        print("Failed to run command '%s'." % ' '.join(cmd))