Пример #1
0
def test_uniqueFn_5():
    ''' test increment method with ext=None 
        file contents: a1.txt, a2.txt, a1.bmp, a2.bmp, a3.bmp
    '''
    TEST_DIR = "../data/test/uniquefn/test5/"

    newFn = uniqueFn(fn_base="a", fn_dir=TEST_DIR, fn_ext=None)

    assert newFn == "a4"
Пример #2
0
def test_uniqueFn_6():
    ''' test increment method with ext=None and multi-dot file names
        file contents: a1.txt, a2.txt, a.diff.1.bmp, a.a2.bmp, a3.bmp
    '''
    TEST_DIR = "../data/test/uniquefn/test6/"

    newFn = uniqueFn(fn_base="a", fn_dir=TEST_DIR, fn_ext=None)

    assert newFn == "a4"
Пример #3
0
def test_uniqueFn_3():
    ''' test increment method with different ext '''

    TEST_DIR = "../data/test/uniquefn/test3/"
    NEW_FN = "testfn1.h264"

    assert NEW_FN not in os.listdir(TEST_DIR)

    newFn = uniqueFn(fn_base="testfn", fn_dir=TEST_DIR, fn_ext="h264")

    assert newFn == NEW_FN
Пример #4
0
def test_uniqueFn_4():
    ''' test increment method with different base_fn '''

    TEST_DIR = "../data/test/uniquefn/test4/"
    NEW_FN = "justfn1.txt"

    assert len(os.listdir(TEST_DIR)) > 0
    assert NEW_FN not in os.listdir(TEST_DIR)

    newFn = uniqueFn(fn_base="justfn", fn_dir=TEST_DIR, fn_ext="txt")

    assert newFn == NEW_FN
Пример #5
0
def test_uniqueFn_1():
    ''' test increment method '''

    TEST_DIR = "../data/test/uniquefn/test1/"
    NEW_FN = "testfn5.txt"

    files = os.listdir(TEST_DIR)

    if NEW_FN in files:
        os.remove(TEST_DIR + NEW_FN)

    files = os.listdir(TEST_DIR)
    assert NEW_FN not in files

    newFn = uniqueFn(fn_base="testfn", fn_dir=TEST_DIR, fn_ext="txt")

    assert newFn == NEW_FN
Пример #6
0
def test_uniqueFn_2():
    ''' test increment method past first digit '''

    TEST_DIR = "../data/test/uniquefn/test2/"
    NEW_FN = "testfn11.txt"

    for i in range(1, 11):
        f = open(TEST_DIR + "testfn" + str(i) + ".txt", "w")
        f.close()

    files = os.listdir(TEST_DIR)
    assert len(files) == 10
    assert NEW_FN not in files

    newFn = uniqueFn(fn_base="testfn", fn_dir=TEST_DIR, fn_ext="txt")

    assert newFn == NEW_FN

    for _f in os.listdir(TEST_DIR):
        os.remove(TEST_DIR + _f)

    assert len(os.listdir(TEST_DIR)) == 0
Пример #7
0
    def initVidWriter(self, frameSize, vidFn):

        ext = "avi"
        fourcc = "h264"
        if self.compressionEnum == 1:
            fourcc = 0  #request lossless encoding

        if self.vidwriter is not None:
            self.vidwriter.release()
            self.vidwriter = None

        fnBase = self.stripExt(vidFn)

        self.writeVidFn = uniqueFn(fn_base=fnBase + ".proc",
                                   fn_dir=self.outputDir,
                                   fn_ext=ext)

        self.vidwriter = VidWriter(savefn=os.path.join(self.outputDir,
                                                       self.writeVidFn),
                                   fourcc=fourcc,
                                   outshape=frameSize)

        if self.timewriter is not None:
            self.timewriter.close()
            self.timewriter = None

        self.writeTimeFn = self.stripExt(self.writeVidFn) + ".txt"

        self.timewriter = open(os.path.join(self.outputDir, self.writeTimeFn),
                               'w')

        self.writeMetaFn = self.stripExt(self.writeVidFn) + ".metalog"

        _f = open(os.path.join(self.outputDir, self.writeMetaFn), 'w')
        _f.close()
        self.metawriter = True
Пример #8
0
def test_uniqueFn_7():
    ''' test guid method '''
    import copy

    results = []

    N = 20
    for trial in range(N):

        results.append(uniqueFn("", method="guid", fn_ext="txt"))

    assert len(results) == N

    assert all(map(lambda fn: len(fn) == 6 + 1 + 3, results))

    for i in range(len(results)):

        _results2 = copy.copy(results)
        _results2.pop(i)
        elem = results[i]

        assert len(_results2) == N - 1

        assert elem not in _results2
Пример #9
0
        cam.set(3, frame_size[0])
        cam.set(4, frame_size[1])
    except:
        print 'couldnt set cam with frame_size: ', str(frame_size)

    metalog = MetaDataLog()

    metalog.set(cam_num=Globals.gui_cam_num,
                frame_size=frame_size,
                fourcc_enum=fourcc,
                b_buffer=Globals.gui_b_buffer)

    gui.myGui.set_sv_dir(init_savedir)  #set directory to gui ang global
    gui.myGui.get_sv_dir()

    fn = uniqueFn(fn_base="output", fn_dir=Globals.gui_dir_path, fn_ext=ext)

    gui.myGui.set_sv_fn(fn)
    gui.myGui.get_sv_fn()

    t0 = time.time()
    reset_cntr += 1

    while (cam.isOpened()):

        try:

            timelog.log_start()

            if not (b_experimental_read):
                ret, frame = cam.read()