Submit this torrent and create a new task
336578
def submit(self):
        """"""
        if self.api._req_lixian_add_task_bt(self):
            self.submitted = True
            return True
        return False
1056261
function task() {

	// generate commit using default global release environment options
	var commitTask = coopt._getCommitTask();
	var commit = commitTask.commit;

	// register or run the release task (depends on task runner)
	rbot.task(commitTask.commitOpts.pluginName, commitTask.commitOpts.pluginDesc,
			function releaseTask() {
				var options = this.options(commitTask.defaultTaskOptions);
				if (options.gitHostname && commit.username) {
					options.hideTokenRegExp = new RegExp('(' + commit.username + ':)([0-9a-f]+)(@'
							+ options.gitHostname + ')');
				}
				release(this, options);
			});

	/**
	 * When a release commit message is received a release is performed and a
	 * repository web site is published
	 * 
	 * @param task
	 *            the currently running task
	 * @param options
	 *            the task options
	 */
	function release(task, options) {
		var doneAsync = null;

		// validate commit
		if (!commit.versionValidate()) {
			return;
		}
		rbot.log.info('Preparing release: ' + commit.version + ' (last release: '
				+ (commit.prev.versionTag ? commit.prev.versionTag : 'N/A') + ')');
		var useGitHub = options.gitHostname.toLowerCase() === github.hostname;

		var tmpltData = genTemplateData('name', 'pkgCurrVerBumpMsg', 'pkgNextVerBumpMsg', 'distBranchPubMsg');

		var chgLogRtn = '', athrsRtn = '', pubHash = '', distAssets = [];
		var distZipAsset = '', distTarAsset = '', distZipAssetName = '', distTarAssetName = '';
		var pubSrcDir = options.distDir ? path.join(commit.buildDir, options.distDir) : commit.buildDir;
		var pubDistDir = options.distBranch ? commit.buildDir.replace(commit.reponame, options.distBranch) : '';

		// initialize library instances
		var rollCall = new RollCall(options);
		var cmdObj = new Cmd(commit, options, rollCall);
		var cmd = cmdObj.cmd;
		var chkoutRun = cmdObj.chkoutRun;
		var pack = new Pack(commit, options, rollCall, cmdObj);

		// start work
		rollCall.then(remoteSetup).then(pkgUpdate).then(changeLog).then(authorsLog).then(addAndCommitDistDir).then(
				genDistAssets);
		rollCall.then(function() {
			if (useGitHub) {
				doneAsync = task.async();
				rollCall.then(gitHubRelease);
			} else {
				rollCall.then(gitRelease);
			}
		});
		// begin release
		rollCall.start(function(rbcnt) {
			var ecnt = rollCall.errorCount();
			var msg = ecnt > 0 ? 'Processed ' + rbcnt + ' rollback action(s)' : 'Released ' + commit.versionTag;
			rbot.log.info(msg);

			// non-critical cleanup
			try {
				if (ecnt <= 0 && tmpltData.pkgNextVerBumpMsg) {
					// bump to next version
					pkgUpdate(null, null, false, true, true);
				}
			} catch (e) {
				rollCall.error('Failed to bump next release version', e);
			}
			try {
				// update the commit task
				coopt._cloneAndSetCommitTask(commitTask);
			} catch (e) {
				rollCall.error('Failed to set global commit result properties', e);
			}

			// complete
			if (doneAsync) {
				doneAsync(ecnt <= 0);
			} else if (ecnt > 0) {
				throw new Error('Release failed');
			}
		});

		/**
		 * Generates an object that contains each of the passed arguments as a
		 * property with a value of an option with the same name. Each property
		 * will have a value for that option that is parsed using the template
		 * processor.
		 * 
		 * @returns the parsed template data
		 */
		function genTemplateData() {
			var templateData = {
				data : {
					process : process,
					commit : commit,
					env : commitTask.commitOpts,
					options : options
				}
			};
			var rtn = {};
			var arr = Array.prototype.slice.call(arguments, 0);
			arr.forEach(function genIntMsgs(s) {
				rtn[s] = options[s] ? rbot.processTemplate(options[s], templateData) : '';
				if (rtn[s]) {
					rbot.log.verbose(s + ' = ' + rtn[s]);
				}
			});
			return rtn;
		}

		/**
		 * Remote Git setup to permit pushes
		 */
		function remoteSetup() {
			var link = '${GH_TOKEN}@' + options.gitHostname + '/' + commit.slug + '.git';
			cmd('git config --global user.email "' + options.repoEmail + '"');
			cmd('git config --global user.name "' + options.repoUser + '"');
			cmd('git remote rm ' + options.repoName);
			cmd('git remote add ' + options.repoName + ' https://' + commit.username + ':' + link);
		}

		/**
		 * Updates the package file version using the current {Commit} version
		 * and commits/pushes it to remote
		 * 
		 * @param altPkgPath
		 *            the alternative path to the package that will be updated
		 * @param altPkgBowerPath
		 *            the alternative path to the bower package that will be
		 *            updated
		 * @param noPush
		 *            true to only update the package file
		 * @param isNext
		 *            true when the version should be updated to the next
		 *            version versus the default current one
		 * @param noRollback
		 *            true to exclude a rollback for the update
		 */
		function pkgUpdate(altPkgPath, altPkgBowerPath, noPush, isNext, noRollback) {
			chkoutRun(commit.branch, upkg, false, isNext);
			if (!noRollback) {
				rollCall.addRollback(function pkgUpdateRollback() {
					chkoutRun(commit.branch, upkg, true);
				});
			}
			function upkg(revert, next) {
				commit.versionPkg({
					replacer : options.pkgJsonReplacer,
					space : options.pkgJsonSpace,
					revert : revert,
					next : next,
					altWrite : pkgWritable,
					altPkgPath : altPkgPath,
					altPkgPathBower : altPkgBowerPath
				}, pkgPush);
			}
			function pkgWritable(pkgData) {
				pkgLog(pkgData, true);
				return pkgData.pkgStr;
			}
			function pkgPush(pd, pdBower) {
				// TODO : check to make sure there isn't any commits ahead of
				// this one
				if (!noPush && (pd.u || pd.r || pd.n)) {
					cmd('git commit -q -m "' + (pd.r ? 'Rollback: ' : '')
							+ (pd.n ? tmpltData.pkgNextVerBumpMsg : tmpltData.pkgCurrVerBumpMsg) + '" ' + pd.p);
					cmd('git push ' + options.repoName + ' ' + commit.branch);
				}
				pkgLog(pd, false);
				pkgLog(pdBower, false);
			}
			function pkgLog(pd, beforeWrite) {
				if (!pd) {
					return;
				}
				var skip = !pd.n && !pd.r && !pd.u;
				var m = (skip ? 'Skip' : pd.r ? 'Revert' : 'Bump') + (beforeWrite ? 'ing' : (skip ? 'p' : '') + 'ed')
						+ (skip ? ' write:' : pd.n ? ' next' : '') + ' version from ' + pd.oldVer + ' to '
						+ pd.pkg.version + ' in ' + pd.path;
				if (pd.r) {
					rbot.log.verbose(m);
				} else {
					rbot.log.info(m);
				}
			}
		}

		/**
		 * Generates/Writes a change log for the current release using all
		 * messages since last tag/release
		 */
		function changeLog() {
			// Generate change log for release using all messages since last
			// tag/release
			if (!options.chgLog) {
				if (options.chgLogRequired) {
					throw new Error('Invalid "options.chgLog": "' + options.chgLog + '" ("options.chgLogRequired": '
							+ options.chgLogRequired + '"');
				}
				return;
			}
			var chgLogPath = path.join(options.distDir, options.chgLog);
			var lastGitLog = commit.prev && !commit.prev.versionVacant() ? commit.prev.versionTag + '..HEAD' : 'HEAD';
			chgLogRtn = cmd('git --no-pager log ' + lastGitLog + ' --pretty=format:"' + options.chgLogLineFormat
					+ '" > ' + chgLogPath, null, false, chgLogPath, options.chgLogSkipRegExps, '<!-- Commit '
					+ commit.hash + ' -->\n')
					|| '';
			utils.validateFile(chgLogPath, rollCall);
		}

		/**
		 * Generates/Writes an authors log for the current release using all
		 * authors since last tag/release
		 */
		function authorsLog() {
			// Generate list of authors/contributors since last tag/release
			if (!options.authors) {
				if (options.authorsRequired) {
					throw new Error('Invalid "options.authors": "' + options.authors + '" ("options.authorsRequired": '
							+ options.authorsRequired + '"');
				}
				return;
			}
			var athrsPath = path.join(options.distDir, options.authors);
			athrsRtn = cmd('git --no-pager shortlog -sen HEAD > ' + athrsPath, null, false, athrsPath,
					options.authorsSkipLineRegExp)
					|| '';
			utils.validateFile(athrsPath, rollCall);
		}

		/**
		 * Adds/Commits everything in the distribution directory for tracking
		 */
		function addAndCommitDistDir() {
			if (commit.pkgPath && options.distDir && !/^(?:\.|\/)[^\.]/.test(options.distDir)) {
				// need to update the package included in the distribution
				pkgUpdate(path.join(options.distDir, commit.pkgPath), commit.pkgPathBower ? path.join(options.distDir,
						commit.pkgPathBower) : null, true, false);
			}
			if (options.distDir || athrsRtn || chgLogRtn) {
				if (options.distDir) {
					cmd('git add --force ' + options.distDir);
				}
				// Commit changes (needed to generate archive asset)
				cmd('git commit -q -m "' + tmpltData.distBranchPubMsg + '"');
			}
		}

		/**
		 * Generates distribution archive assets (i.e. zip/tar)
		 */
		function genDistAssets() {
			if (!options.distDir) {
				rbot.log.info('Skipping generation of distribution assets (no distDir)');
				return;
			}
			if (!options.distAssetDir) {
				rbot.log.info('Skipping generation of distribution assets (no distAssetDir)');
				return;
			}
			// give taskateers a chance to update branch file contents
			utils.updateFiles(options.distAssetUpdateFiles, options.distAssetUpdateFunction, commit.buildDir,
					rollCall.error);
			// Create distribution assets
			distZipAssetName = commit.reponame + '-' + commit.version + '-dist.zip';
			distZipAsset = genAsset(distZipAssetName, 'zip', true, 'application/zip');
			distTarAssetName = commit.reponame + '-' + commit.version + '-dist.tar.gz';
			distTarAsset = genAsset(distTarAssetName, 'tar.gz', false, 'application/x-compressed');

			/**
			 * Generates an Git archive asset and pushes an object
			 * w/path/name/contentType to the distribution assets {Array}
			 * 
			 * @param name
			 *            the name of the asset file
			 * @param type
			 *            the type/format the asset represents
			 * @param compress
			 *            true to add the compression ratio to the Git command
			 * @param ct
			 *            the Content-Type
			 * @returns the file path to the asset
			 */
			function genAsset(name, type, compress, ct) {
				var a = path.resolve(options.distAssetDir, name);
				cmd('git archive -o "' + a + '" --format=' + type
						+ (compress ? ' -' + options.distAssetCompressRatio : '') + ' HEAD:' + options.distDir);
				if (rbot.log.verboseEnabled) {
					rbot.log.verbose('Created ' + a + ' (size: ' + fs.statSync(a).size + ')');
				}
				distAssets.push({
					path : a,
					name : name,
					contentType : ct
				});
				return a;
			}
		}

		/**
		 * Tags release via standard Git CLI
		 */
		function gitRelease() {
			// Tag release
			rbot.log.info('Tagging release ' + commit.versionTag + ' via ' + options.gitHostname);
			cmd('git tag -f -a ' + commit.versionTag + ' -m "'
					+ (chgLogRtn ? chgLogRtn.replace(coopt.regexLines, '$1 \\') : commit.message) + '"');
			cmd('git push -f ' + options.repoName + ' ' + commit.versionTag);
			commit.releaseId = commit.versionTag;
			// TODO : upload asset?
			rollCall.addRollback(rollbackTag);
			rollCall.then(publish);
		}

		/**
		 * Calls the GitHub Release API to tag release and upload optional
		 * distribution asset
		 */
		function gitHubRelease() {
			rbot.log.info('Releasing ' + commit.versionTag + ' via ' + options.gitHostname);
			// GitHub Release API will not remove the tag when removing a
			// release
			github.releaseAndUploadAsset(distAssets, coopt.regexLines, commit, tmpltData.name, chgLogRtn
					|| commit.message, options, rollCall, rollbackTag, function() {
				rollCall.then(publish);
			});
		}

		/**
		 * Publish repository pages to distribution branch (commit should have a
		 * valid ID)
		 */
		function publish() {
			if (!options.distBranch) {
				rbot.log.info('Skipping publishing from "' + pubSrcDir + '" to ' + pubDistDir + ' (no distBranch)');
				return;
			} else if (!commit.releaseId) {
				rbot.log.info('Skipping publishing from "' + pubSrcDir + '" to "' + pubDistDir + '" in branch "'
						+ options.distBranch + '" (no releaseId/tag)');
				return;
			}
			rbot.log.info('Publishing to branch "' + options.distBranch + '"');
			rbot.log.info('Copying publication directories/files from "' + pubSrcDir + '" to "' + pubDistDir + '"');
			// copy all directories/files over that need to be published
			// so that they are not removed by the following steps
			rbot.log.info(utils.copyRecursiveSync(pubSrcDir, pubDistDir, options.distExcludeDirRegExp,
					options.distExcludeFileRegExp).toString());
			// cmd('cp -r ' + path.join(pubSrcDir, '*') + ' ' + pubDistDir);
			chkoutRun(null, publishRun);
			function publishRun() {
				try {
					cmd('git fetch ' + options.repoName + ' ' + options.distBranch);
					pubHash = cmd('git rev-parse HEAD');
				} catch (e) {
					if (util.isRegExp(options.distBranchCreateRegExp) && options.distBranchCreateRegExp.test(e.message)) {
						cmd('git checkout -q --orphan ' + options.distBranch);
					} else {
						throw e;
					}
				}
				if (pubHash) {
					cmd('git checkout -q --track ' + options.repoName + '/' + options.distBranch);
				}
				cmd('git rm -rfq .');
				cmd('git clean -dfq .');
				rbot.log.info('Copying publication directories/files from "' + pubDistDir + '" to "' + commit.buildDir
						+ '"');
				rbot.log.info(utils.copyRecursiveSync(pubDistDir, commit.buildDir).toString());
				// cmd('cp -r ' + path.join(pubDistDir, '*') + '
				// .');

				// give taskateers a chance to update branch file
				// contents
				utils.updateFiles(options.distBranchUpdateFiles, options.distBranchUpdateFunction, commit.buildDir,
						rollCall.error);

				cmd('git add -A');
				cmd('git commit -q -m "' + tmpltData.distBranchPubMsg + '"');
				cmd('git push -f ' + options.repoName + ' ' + options.distBranch);

				rollCall.addRollback(rollbackPublish);
				rollCall.then(pack.publish);
			}
		}

		/**
		 * Deletes tag using Git CLI
		 */
		function rollbackTag() {
			cmd('git push --delete ' + options.repoName + ' ' + commit.versionTag);
		}

		/**
		 * Reverts published branch
		 */
		function rollbackPublish() {
			try {
				chkoutRun(options.distBranch, function() {
					var cph = cmd('git rev-parse HEAD');
					if (pubHash && pubHash !== cph) {
						cmd('git checkout -qf ' + pubHash);
						cmd('git commit -q -m "Rollback: ' + tmpltData.distBranchPubMsg + '"');
						cmd('git push -f ' + options.repoName + ' ' + options.distBranch);
					} else if (!pubHash) {
						cmd('git push ' + options.repoName + ' --delete ' + options.distBranch);
					} else {
						rbot.log.verbose('Skipping rollback for ' + options.distBranch + ' for hash "' + pubHash
								+ '" (current hash: "' + cph + '")');
					}
				});
			} catch (e) {
				var msg = 'Failed to rollback publish branch changes!';
				rollCall.error(msg, e);
			}
		}
	}
}
698733
def submit(self, func, *args, **kwargs):
        """"""

        with self._shutdown_lock:
            if PY3 and self._broken:
                raise BrokenProcessPool(
                    "A child process terminated "
                    "abruptly, the process pool is not usable anymore"
                )
            if self._shutdown_thread:
                raise RuntimeError("cannot schedule new futures after shutdown")
            callback = kwargs.pop("callback", self.default_callback)
            future = NewFuture(
                self._timeout,
                args,
                kwargs,
                callback=callback,
                catch_exception=self.catch_exception,
            )
            w = _WorkItem(future, func, args, kwargs)
            self._pending_work_items[self._queue_count] = w
            self._work_ids.put(self._queue_count)
            self._queue_count += 1
            self._result_queue.put(None)
            self._start_queue_management_thread()
            if PY2:
                self._adjust_process_count()
            self._all_futures.add(future)
            return future
268195
def add_task(self, subject, status, **attrs):
        
        return Tasks(self.requester).create(
            self.project, subject, status,
            user_story=self.id, **attrs
        )
906363
def create_task(client, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None):
    ''' 
    
    '''
    _check_title_length(title, client.api)
    if (recurrence_type is None and recurrence_count is not None) or (recurrence_type is not None and recurrence_count is None):
        raise ValueError("recurrence_type and recurrence_count are required are required together")
    if due_date is not None:
        _check_date_format(due_date, client.api)
    data = {
            'list_id' : int(list_id) if list_id else None,
            'title' : title,
            'assignee_id' : int(assignee_id) if assignee_id else None,
            'completed' : completed,
            'recurrence_type' : recurrence_type,
            'recurrence_count' : int(recurrence_count) if recurrence_count else None,
            'due_date' : due_date,
            'starred' : starred,
            }
    data = { key: value for key, value in data.items() if value is not None }
    response = client.authenticated_request(client.api.Endpoints.TASKS, 'POST', data=data)
    return response.json()
390025
def create_task(coro, loop):
    # pragma: no cover
    """"""
    if hasattr(loop, 'create_task'):
        return loop.create_task(coro)
    return asyncio.Task(coro, loop=loop)
438973
def create_task(self, list_id, title, assignee_id=None, completed=None, recurrence_type=None, recurrence_count=None, due_date=None, starred=None):
        '''  '''
        return tasks_endpoint.create_task(self, list_id, title, assignee_id=assignee_id, completed=completed, recurrence_type=recurrence_type, recurrence_count=recurrence_count, due_date=due_date, starred=starred)
126046
def new(self, command, attach=""):
        
        r = self._h._http_resource(
            method='POST',
            resource=('apps', self.app.name, 'ps',),
            data={'attach': attach, 'command': command}
        )

        r.raise_for_status()
        return self.app.processes[r.json()['process']]
141552
protected synchronized void submit() {
    try {
      if (theJobConf.getBoolean("create.empty.dir.if.nonexist", false)) {
        FileSystem fs = FileSystem.get(theJobConf);
        Path inputPaths[] = FileInputFormat.getInputPaths(theJobConf);
        for (int i = 0; i < inputPaths.length; i++) {
          if (!fs.exists(inputPaths[i])) {
            try {
              fs.mkdirs(inputPaths[i]);
            } catch (IOException e) {

            }
          }
        }
      }
      RunningJob running = jc.submitJob(theJobConf);
      this.mapredJobID = running.getID();
      this.state = Job.RUNNING;
    } catch (IOException ioe) {
      this.state = Job.FAILED;
      this.message = StringUtils.stringifyException(ioe);
    }
  }
1016854
def do_create(config, config_dir):
    
    if os.path.exists(config_dir):
        print "Configuration '{}' already exists.".format(config)
        exit(1)
    os.makedirs(config_dir)
    print "Configuration directory created."

    url = raw_input("RSS URL for processing []: ")
    torrent_dir = raw_input("Output directory for found .torrent files [{}]: "\
        .format(DEFAULT_TORRRENT_DIR)) or DEFAULT_TORRRENT_DIR
    update_interval = raw_input("Update interval (mins) [{}]: "\
        .format(DEFAULT_UPDATE_INTERVAL)) or DEFAULT_UPDATE_INTERVAL

    editor = os.environ["EDITOR"]

    config_filter = os.path.join(config_dir, 'filter')
    if confirm("Do you want to create filters list?", False):
        call([editor, config_filter])
        print "Filter configuration has been saved."

    config_blacklist = os.path.join(config_dir, 'blacklist')
    if confirm("Do you want to create blacklist?", False):
        call([editor, config_filter])
        print "Blacklist configuration has been saved."

    config_file = os.path.join(config_dir, 'config')
    config_data = json.dumps({
        "url": url,
        "torrent_dir": torrent_dir,
        "update_interval": update_interval
    }, sort_keys=True, indent=4, separators=(',', ': '))
    with open(config_file, 'w') as f:
        f.write(config_data)

    ct = CronTab(user=True)
    cmd = "{} {} -e {}".format(sys.executable,
                               os.path.abspath(__file__),
                               config)
    job = ct.new(command=cmd)
    job.minute.every(update_interval)
    job.enable()
    ct.write()
    print "Crontab updated."

    print "Config '{}' has been saved.".format(config)
1363866
def add_subtask(self, task, params={}, **options): 
        
        path = "/tasks/%s/subtasks" % (task)
        return self.client.post(path, params, **options)
1048485
def run(self):
    """"""
    cmd = ['gsutil', 'ls', os.path.join(self.source_dir, '**')]
    try:
      files_list = subprocess.check_output(cmd).split('\n')
    except subprocess.CalledProcessError:
      logging.error('Can''t read source directory')
    all_submissions = [
        s for s in files_list
        if s.endswith('.zip') or s.endswith('.tar') or s.endswith('.tar.gz')
    ]
    for submission_path in all_submissions:
      self.validate_and_copy_one_submission(submission_path)
    self.stats.log_stats()
    self.save_id_to_path_mapping()
    if self.containers_file:
      with open(self.containers_file, 'w') as f:
        f.write('\n'.join(sorted(self.list_of_containers)))
53832
private void submitTask(@NotNull State<T, R> state, @NotNull BatchItem item, @NotNull Link auth) {
    // Submit task
    final StateHolder holder = new StateHolder(state);
    try {
      state.auth = auth;
      final Work<R> worker = objectTask(state, item);
      if (state.future.isDone()) {
        holder.close();
        return;
      }
      if (worker == null) {
        throw new IllegalStateException("Uncompleted task worker is null: " + item);
      }
      executeInPool(
          "task: " + state.getMeta().getOid(),
          () -> processObject(state, auth, worker),
          holder::close,
          true
      );
    } catch (Throwable e) {
      holder.close();
      throw e;
    }
  }
1144742
def create_task(self, *command_tokens, **command_env):
		
		return self.__scheduled_task_cls(self.basic_command(), *command_tokens, **command_env)
1325160
def do_POST(self):
        """"""
        logging.debug("New POST request.")

        query = parse_qs(urlparse(self.path).query)
        sample = query['sample'][0]
        async = bool(int(query.get('async', [False])[0]))

        path = self.store_file(mkdtemp(), sample)
        command = query['command'][0].format(sample=path).split(' ')

        output = run_command(command, asynchronous=async)

        self.respond(output)
235866
def add_file_task(self, dir_name=None):
        ''''''
        file_dialog = Gtk.FileChooserDialog(_('Choose Files..'),
                self.app.window, Gtk.FileChooserAction.OPEN,
                (Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL,
                 Gtk.STOCK_OK, Gtk.ResponseType.OK))
        file_dialog.set_modal(True)
        file_dialog.set_select_multiple(True)
        file_dialog.set_default_response(Gtk.ResponseType.OK)
        response = file_dialog.run()
        if response != Gtk.ResponseType.OK:
            file_dialog.destroy()
            return
        source_paths = file_dialog.get_filenames()
        file_dialog.destroy()
        if source_paths:
            self.upload_files(source_paths, dir_name)
1143586
void submit(final LoadAndDisplayImageTask task) {
		taskDistributor.execute(new Runnable() {
			@Override
			public void run() {
				File image = configuration.diskCache.get(task.getLoadingUri());
				boolean isImageCachedOnDisk = image != null && image.exists();
				initExecutorsIfNeed();
				if (isImageCachedOnDisk) {
					taskExecutorForCachedImages.execute(task);
				} else {
					taskExecutor.execute(task);
				}
			}
		});
	}