def local_playlist(self):
     self.playlist = list()
     self.get_videolist()
     video_locations = list()
     for location in self.enabled_locations:
         for path in self.local_locations:
             path = os.path.join(c.download_folder, path)
             if location in path:
                 if not "My Videos" in location:
                     for quality in c.get_quality():
                         qual_path = c.validatePath(os.path.join(path, quality))
                         data = {qual_path:location}
                         video_locations.append(data)
                 else:
                     data = {path:location}
                     video_locations.append(data)
     for item  in video_locations:
         for path in item.keys():
             location = item[path]
             for video in c.listdir(path, files=True):
                 if not re.search(c.excludes, video):
                     video_path = c.validatePath(os.path.join(path, video))
                     id = os.path.splitext(video)[0]
                     for item in self.videolist:
                         if item[0] in location:
                             for video in item[1]:
                                 if id in video["id"]:
                                     self.process_video_data(item[0], [video], video_path)
     return self.playlist
Пример #2
0
def main():
    parser = argparse.ArgumentParser()

    g = parser.add_mutually_exclusive_group(required=True)
    g.add_argument('-a',
                   '--all',
                   action='store_true',
                   help='Run tests against all challenge binaries')

    g.add_argument('-c',
                   '--chals',
                   nargs='+',
                   type=str,
                   help='List of challenge names to test')

    g = parser.add_mutually_exclusive_group()
    g.add_argument('--povs',
                   action='store_true',
                   help='Only run tests against POVs')

    g.add_argument('--polls',
                   action='store_true',
                   help='Only run tests against POLLS')

    parser.add_argument(
        '-o',
        '--output',
        default=None,
        type=str,
        help=
        'If provided, an excel spreadsheet will be generated and saved here')

    args = parser.parse_args(sys.argv[1:])

    # Disable other tests depending on args
    if args.povs:
        Tester.polls_enabled = False
    if args.polls:
        Tester.povs_enabled = False

    if args.all:
        debug('Running tests against all challenges\n')
        tests = test_challenges(listdir(BUILD_DIR))
    else:
        debug('Running tests against {} challenge(s)\n'.format(len(
            args.chals)))
        tests = test_challenges(args.chals)

    if args.output:
        generate_xlsx(os.path.abspath(args.output), tests)
Пример #3
0
def print_affects (affects):

    "Shows all files, which are affected by a blacklist-rule"

    affectresults = []

    # Add all matching lines to results

    if os.path.exists(myconfig['savedir'] + "lists/" + playlist):
        listfile = open (myconfig['savedir'] + "lists/" + playlist, 'r')
        for line in listfile.readlines():
            line = line.replace(mediadir, '', 1)[:-1]
            if re.compile(affects).search(line) != None:
                affectresults.append(line)
        listfile.close()

    # Sort results alphabetically

    if affectresults != []:
        affectresults.sort()
        common.results = affectresults
        common.listdir('/', 0,'file2')
    else:
        print "<p>No songs match these rule.</p>"
Пример #4
0
def print_affects(affects):

    "Shows all files, which are affected by a blacklist-rule"

    affectresults = []

    # Add all matching lines to results

    if os.path.exists(myconfig['savedir'] + "lists/" + playlist):
        listfile = open(myconfig['savedir'] + "lists/" + playlist, 'r')
        for line in listfile.readlines():
            line = line.replace(mediadir, '', 1)[:-1]
            if re.compile(affects).search(line) != None:
                affectresults.append(line)
        listfile.close()

    # Sort results alphabetically

    if affectresults != []:
        affectresults.sort()
        common.results = affectresults
        common.listdir('/', 0, 'file2')
    else:
        print "<p>No songs match these rule.</p>"
Пример #5
0
    def run(self):
        """Runs all tests for this challenge binary"""
        debug('\nTesting {}...\n'.format(self.name))

        # Test POVs
        if Tester.povs_enabled:
            debug('POV:\n\t')
            self.run_against_dir(self.bin_dir, self.povs, is_pov=True)

        # Test POLLs
        if Tester.polls_enabled:
            debug('POLL:\n')
            for subdir in listdir(self.poll_dir):
                debug('\t{}:\t'.format(subdir))
                self.run_against_dir(os.path.join(self.poll_dir, subdir), self.polls)
        debug('Done testing {} => Passed {}/{} tests\n'.format(self.name, self.passed, self.total))
Пример #6
0
 def local_playlist(self):
     self.playlist = list()
     self.get_videolist()
     video_locations = list()
     for location in self.enabled_locations:
         for path in self.local_locations:
             path = os.path.join(c.download_folder, path)
             if location in path:
                 if not "My Videos" in location:
                     for quality in c.get_quality():
                         qual_path = c.validatePath(
                             os.path.join(path, quality))
                         beta(qual_path)
                         if not c.exists(qual_path + "/"):
                             beta("Going to download a new video.")
                             local_videos.Downloader(mode=1).download()
                             return "restart"
                         data = {qual_path: location}
                         video_locations.append(data)
                 else:
                     data = {path: location}
                     video_locations.append(data)
     if self.len_check(video_locations):
         return "restart"
     else:
         found = 0
         for item in video_locations:
             for path in item.keys():
                 location = item[path]
                 for video in c.listdir(path, files=True):
                     beta("Found: {}".format(video))
                     found += 1
                     if not re.search(c.excludes, video):
                         video_path = c.validatePath(
                             os.path.join(path, video))
                         id = os.path.splitext(video)[0]
                         for item in self.videolist:
                             if item[0] in location:
                                 for video in item[1]:
                                     if id in video["id"]:
                                         self.process_video_data(
                                             item[0], [video], video_path)
         if found == 0:
             return "restart"
         else:
             return self.playlist
Пример #7
0
    def run(self):
        """Runs all tests for this challenge binary"""
        debug('\nTesting {}...\n'.format(self.name))

        # Test POVs
        if Tester.povs_enabled:
            debug('POV:\n\t')
            self.run_against_dir(self.bin_dir, self.povs, is_pov=True)

        # Test POLLs
        if Tester.polls_enabled:
            debug('POLL:\n')
            for subdir in listdir(self.poll_dir):
                debug('\t{}:\t'.format(subdir))
                self.run_against_dir(os.path.join(self.poll_dir, subdir),
                                     self.polls)
        debug('Done testing {} => Passed {}/{} tests\n'.format(
            self.name, self.passed, self.total))
Пример #8
0
def main():
    parser = argparse.ArgumentParser()

    g = parser.add_mutually_exclusive_group(required=True)
    g.add_argument('-a', '--all', action='store_true',
                   help='Run tests against all challenge binaries')

    g.add_argument('-c', '--chals', nargs='+', type=str,
                   help='List of challenge names to test')

    g = parser.add_mutually_exclusive_group()
    g.add_argument('--povs', action='store_true',
                   help='Only run tests against POVs')

    g.add_argument('--polls', action='store_true',
                   help='Only run tests against POLLS')

    parser.add_argument('-o', '--output',
                        default=None, type=str,
                        help='If provided, an excel spreadsheet will be generated and saved here')

    args = parser.parse_args(sys.argv[1:])

    # Disable other tests depending on args
    if args.povs:
        Tester.polls_enabled = False
    if args.polls:
        Tester.povs_enabled = False

    if args.all:
        debug('Running tests against all challenges\n')
        tests = test_challenges(listdir(BUILD_DIR))
    else:
        debug('Running tests against {} challenge(s)\n'.format(len(args.chals)))
        tests = test_challenges(args.chals)

    if args.output:
        generate_xlsx(os.path.abspath(args.output), tests)
Пример #9
0
    print "<p>" + common.get_cover(mediadir + givendir, myconfig['coverwidth']) + "</p>"
elif not os.path.exists(mediadir + givendir):
    # if $mediadir == "/": just build filelist, no dir-splitting needed
    print "<h1>Error!</h1>"
    print "The directory " + givendir + " could not be found."
    print "</body></html>"

if viewplaylist and 'playlist' in form:
    allfiles = []
    playlistfile = open(myconfig['savedir'] + "lists/" + form['playlist'].value)
    for line in playlistfile.readlines():
        line = line.replace(mediadir, '', 1)
        allfiles.append(line[:-1])
    playlistfile.close()
    common.results = allfiles
    common.listdir('/', 0, 'file2', 0, urllib.quote(playlist))
    print "</div></body></html>"
    sys.exit(0)

files = []
dirs = []  # All files and directories which should be displayed

if 'playlist' in form and not 'mode' in form:
    # Browse playlist

    playlist = form['playlist'].value
    playlist = re.sub('//', '/', playlist)
    playlist = re.sub('../', '', playlist)
    if playlist == '..':
        playlist = ''
Пример #10
0
    print "<p>" + common.get_cover(mediadir + givendir, myconfig['coverwidth']) + "</p>"
elif not os.path.exists(mediadir + givendir):
    # if $mediadir == "/": just build filelist, no dir-splitting needed
    print "<h1>Error!</h1>"
    print "The directory " + givendir + " could not be found."
    print "</body></html>"

if viewplaylist and 'playlist' in form:
    allfiles = []
    playlistfile = open(myconfig['savedir'] + "lists/" + form['playlist'].value)
    for line in playlistfile.readlines():
        line = line.replace(mediadir, '', 1)
        allfiles.append(line[:-1])
    playlistfile.close()
    common.results = allfiles
    common.listdir('/', 0, 'file2', 0, playlist)
    print "</div></body></html>"
    sys.exit(0)

files = []
dirs = []  # All files and directories which should be displayed

if 'playlist' in form and not 'mode' in form:
    # Browse playlist

    playlist = form['playlist'].value
    playlist = re.sub('//', '/', playlist)
    playlist = re.sub('../', '', playlist)
    if playlist == '..':
        playlist = ''
Пример #11
0
                results.append(line[:-1])
    elif searchtype == 'regex':
        for line in listlines:
            line = line.replace(mediadir, '', 1)
            name = line[:-5]
            matcher = re.match(search, name)
            if matcher is not None:
                results.append(line[:-1])

    # Sort results alphabetically

    results.sort()
    common.results = results
    results = common.sort_results('/')

    # List directory in browser

    if results:
        common.results = results
        if editplaylist:
            common.listdir('/', 0, cssclass, 2, urllib.quote(form['playlist'].value))
        else:
            common.listdir('/', 0, cssclass)
    else:
        print "<p>" + _("No songs found.") + "</p>"

else:
    print "<p>" + _("Please enter at least three characters as a search criterion.") + "</p>"

print "</body></html>"
Пример #12
0
elif not os.path.exists(mediadir + givendir):
    # if $mediadir == "/": just build filelist, no dir-splitting needed
    print "<h1>Error!</h1>"
    print "The directory " + givendir + " could not be found."
    print "</body></html>"

if viewplaylist and 'playlist' in form:
    allfiles = []
    playlistfile = open(myconfig['savedir'] + "lists/" +
                        form['playlist'].value)
    for line in playlistfile.readlines():
        line = line.replace(mediadir, '', 1)
        allfiles.append(line[:-1])
    playlistfile.close()
    common.results = allfiles
    common.listdir('/', 0, 'file2', 0, playlist)
    print "</div></body></html>"
    sys.exit(0)

files = []
dirs = []  # All files and directories which should be displayed

if 'playlist' in form and not 'mode' in form:
    # Browse playlist

    playlist = form['playlist'].value
    playlist = re.sub('//', '/', playlist)
    playlist = re.sub('../', '', playlist)
    if playlist == '..':
        playlist = ''
Пример #13
0
                results.append(line[:-1])
    elif searchtype == 'regex':
        for line in listlines:
            line = line.replace(mediadir, '', 1)
            name = line[:-5]
            matcher = re.match(search, name)
            if matcher is not None:
                results.append(line[:-1])

    # Sort results alphabetically

    results.sort()
    common.results = results
    results = common.sort_results('/')

    # List directory in browser

    if results:
        common.results = results
        if editplaylist:
            common.listdir('/', 0, cssclass, 2, form['playlist'].value)
        else:
            common.listdir('/', 0, cssclass, 0, playlist)
    else:
        print "<p>" + _("No songs found.") + "</p>"

else:
    print "<p>" + _("Please enter at least three characters as a search criterion.") + "</p>"

print "</body></html>"