Exemplo n.º 1
0
def database_task_run():
    # 获取任务文件目录
    task_files_dir = os.path.join(os.path.dirname(__file__), "tasks")

    # 获取任务文件列表
    task_file_names = os.listdir(task_files_dir)

    # 输出所有文件和文件夹
    for task_file_name in task_file_names:
        if task_file_name.index('.') == 0:
            continue
        task_file_path = os.path.join(task_files_dir,
                                      task_file_name).replace("\\", "/")
        tasker = Tasker(task_file_path)
        tasker.run()
Exemplo n.º 2
0
def TaskerDo(argv):
    try:
        if len(argv) != 4 and len(argv) != 5:
            usage()

        if len(argv) >= 4:
            taskfile = argv[2]
            projectname = argv[3]
        if len(argv) == 5:
            path = argv[4] + os.sep
        else:
            path = os.getcwd() + os.sep

        tasker = Tasker()
        tasker.processTask(taskfile, projectname, path)
        tasker.runAnnotator(taskfile, projectname, path)

        tasktime = os.path.getmtime(taskfile)
        modifiedlist = tasker.listModified(taskfile, projectname, path).strip()
        if modifiedlist == '':
            modifiedlist = []
        else:
            modifiedlist = modifiedlist.split('\n')

        if len(modifiedlist) == 0:
            print "\n - No descriptor pool modified. Exiting without uploading anything.\n"
        else:
            print "\n - The following descriptor pools will be uploaded:\n  -" + (
                '\n  - ').join(modifiedlist)
            answer = raw_input("\n > Do you want to do it? (y/n)  ")
            if answer.strip() == 'y':
                if tasker.uploadChanges(taskfile, projectname, path) == -1:
                    print "\n - Error uploading descriptors\n"
                else:
                    print "\n - Descriptors uploaded OK\n"
            else:
                print "\n - No descriptor uploaded\n"
        #tasker.clean()
    except TaskerError, err:
        print >> sys.stderr, err
        sys.exit(-1)
Exemplo n.º 3
0
def main(args):
    global app, form, tasker, window

    app = QtGui.QApplication(args)
    window = QtGui.QDialog()
    form = Ui_GUI()
    form.setupUi(window)
    window.show()

    initWidgets()
    if len(args) > 1:
        form.taskEdit.setText(args[1])
        form.projectEdit.setText(os.path.split(args[1])[1].split('.task')[0])
    if len(args) > 2:
        form.projectEdit.setText(args[2])
    createConnections()

    tasker = Tasker(form.logEdit.append)

    sys.exit(app.exec_())
Exemplo n.º 4
0
def TaskerDo( argv ):
	try:
		if len( argv ) != 4 and len( argv ) != 5:
			usage()

		if len( argv ) >= 4:
			taskfile = argv[2]
			projectname = argv[3]
		if len (argv ) == 5:
			path =  argv[4] + os.sep
		else:
			path = os.getcwd() + os.sep

		tasker=Tasker()
		tasker.processTask( taskfile, projectname, path )
		tasker.runAnnotator( taskfile, projectname, path )
		
		tasktime = os.path.getmtime( taskfile )
		modifiedlist = tasker.listModified( taskfile, projectname, path ).strip()
		if modifiedlist == '':
			modifiedlist = []
		else:
			modifiedlist = modifiedlist.split('\n')

		if len( modifiedlist )==0:
			print "\n - No descriptor pool modified. Exiting without uploading anything.\n"
		else:
			print "\n - The following descriptor pools will be uploaded:\n  -" + ( '\n  - ' ).join( modifiedlist )
			answer = raw_input( "\n > Do you want to do it? (y/n)  " ) 
			if answer.strip() == 'y':
				if tasker.uploadChanges( taskfile, projectname, path ) == -1:
					print "\n - Error uploading descriptors\n"
				else:
					print "\n - Descriptors uploaded OK\n"
			else:
				print "\n - No descriptor uploaded\n"
		#tasker.clean()
	except TaskerError, err:
		print >> sys.stderr, err
		sys.exit(-1)
Exemplo n.º 5
0
def TaskerProcesstask( argv ):
	if len( argv ) != 5:
		usage()
	
	tasker=Tasker()
	tasker.processTask( argv[2], argv[3], argv[4] )
Exemplo n.º 6
0
def TaskerClean( argv ):
	if len( argv ) != 2:
		usage()
	
	tasker=Tasker()
	tasker.clean( argv[2], argv[3], argv[4] )
Exemplo n.º 7
0
def TaskerUpload( argv ):
	if len( argv ) != 5:
		usage()
	
	tasker=Tasker()
	tasker.uploadChanges( argv[2], argv[3], argv[4] )
Exemplo n.º 8
0
def TaskerListmodified( argv ):
	if len( argv ) != 5:
		usage()
	
	tasker=Tasker()
	sys.stdout.write(tasker.listModified( argv[2], argv[3], argv[4] ))
Exemplo n.º 9
0
def TaskerRunannotator( argv ):
	if len( argv ) != 5:
		usage()
	
	tasker=Tasker()
	tasker.runAnnotator( argv[2], argv[3], argv[4] )
Exemplo n.º 10
0
def TaskerProcesstask(argv):
    if len(argv) != 5:
        usage()

    tasker = Tasker()
    tasker.processTask(argv[2], argv[3], argv[4])
Exemplo n.º 11
0
def TaskerClean(argv):
    if len(argv) != 2:
        usage()

    tasker = Tasker()
    tasker.clean(argv[2], argv[3], argv[4])
Exemplo n.º 12
0
def TaskerUpload(argv):
    if len(argv) != 5:
        usage()

    tasker = Tasker()
    tasker.uploadChanges(argv[2], argv[3], argv[4])
Exemplo n.º 13
0
def TaskerListmodified(argv):
    if len(argv) != 5:
        usage()

    tasker = Tasker()
    sys.stdout.write(tasker.listModified(argv[2], argv[3], argv[4]))
Exemplo n.º 14
0
def TaskerRunannotator(argv):
    if len(argv) != 5:
        usage()

    tasker = Tasker()
    tasker.runAnnotator(argv[2], argv[3], argv[4])
Exemplo n.º 15
0
	def setUp(self):
		self.tasker = Tasker(nullPrint)
Exemplo n.º 16
0
class TaskerTest ( unittest.TestCase ) :
	def setUp(self):
		self.tasker = Tasker(nullPrint)

	def testRetrieveTask_nonExistingorIncorrectTaskFile(self):
		try:
			self.tasker.retrieveTask( "nonexisting.file" )
			self.fail( "A TaskerError should have been thrown given a non-existing task file" )
		except TaskerError:
			pass
		try:
			self.tasker.retrieveTask( StringIO("<I am a wrong XML file!!!") )
			self.fail( "A TaskerError should have been thrown given a non-existing task file" )
		except TaskerError:
			pass

	def testExtractParameters_correctFile(self):
		self.tasker.setParameters( taskfile, "Project" )
		ids, descs, cl, mp, description = self.tasker.extractParameters() 

		self.assertEquals( ids, ['69'] )
		self.assertEquals( descs, ['Song::Artist','Song::Title'] )
		self.assertEquals( cl,'http://localhost/SimacServices/ContentLocator' )
		self.assertEquals( mp,'http://localhost/SimacServices/MetadataProvider' )
		self.assertEquals( description,'This is a really nice task' )

	def testExtractParameters_wrongFile(self):
		self.tasker.setParameters( wrongtaskfile, "Project" )
		try:
			ids, descs, cl, mp = self.tasker.extractParameters() 
		except TaskerError:
			pass
		else:
			self.fail("A TaskError should have been thrown")
	
	def testCreateFile(self):
		self.tasker.createFile('erase', '.me', 'this is a content')
		file = open('erase.me')
		self.assertEquals( file.read(), 'this is a content')
		os.remove('erase.me')

	def testDownloadSong_noLocationsSpecified(self):
		result=self.tasker.downloadSong("")
		self.assertEquals( result, None)

	def testDownloadSong_noValidLocations(self):
		result=self.tasker.downloadSong( "invalidpath\noh://my.god" )
		self.assertEquals( result, None)