Get a handler that calls Jenkins API to copy a job into a new job.
Success job copy message will be logged when there's no error.

@param {Function} cb: callback for argument handling
@return Jenkins API handler function
423765
function copy(cb) {
  return function (existingName, newName, args) {
    function resultCb(result) {
      console.log(text.__('Job %s was copied to job %s'), existingName, newName);
    }
    function jenkinsCb(jenkins) {
      jenkins.copyJob(existingName, newName, cli.exitCb(null, resultCb));
    }
    cb(args, jenkinsCb);
  };
}
1307627
function (o, cb) {
    if (!o.out) {
      throw new Error('output dir missing');
    }

    this.src(o)
      .on('error', handleCallbackError(cb))
      .pipe(vfs.dest(function (file) {
        return file.base;
      }))
      .on('error', handleCallbackError(cb))
      .on('end', function () {
        if (_.isFunction(cb) && !error) {
          cb();
        }
      });
  }
883603
function(nameOrDir, cb) {
    var errorPrefix, onError, onSuccess;

    // Strip any leading slash
    if (nameOrDir && nameOrDir.substr(0, 1) === '/') {
      nameOrDir = nameOrDir.substr(1);
    }

    // Check for errors. Note this feature requires jQuery at the moment
    errorPrefix = 'SocketStream Error: The ss.load.code() command ';
    if (!jQuery) {
      return console.error(errorPrefix + 'requires jQuery to be present');
    }
    if (!nameOrDir) {
      return console.error(errorPrefix + 'requires a directory to load. Specify it as the first argument. '+
        'E.g. The ss.load.code(\'/mail\',cb) will load code in /client/code/mail');
    }
    if (!cb) {
      return console.error(errorPrefix + 'requires a callback. Specify it as the last argument');
    }

    // If we've loaded this module or package before, callback right away
    if (async.loaded[nameOrDir]) {
      return cb();
    }

    // Else, register callback and use EE to prevent multiple reqs for the same mod/package to the server before the first responds
    async.loading.once(nameOrDir, cb);

    // Retrieve module or directory of modules from the server if this is the first request
    if (async.loading.listeners(nameOrDir).length === 1) {
      onError = function() {
        console.error('SocketStream Error: Could not asynchronously load ' + nameOrDir);
        return console.log(arguments);
      };
      onSuccess = function() {
        async.loaded[nameOrDir] = true;
        return async.loading.emit(nameOrDir);
      };

      // Send request to server
      return $.ajax({
        url: '/assets/ondemand/' + nameOrDir,
        type: 'GET',
        cache: false,
        dataType: 'script',
        success: onSuccess,
        error: onError
      });
    }
  }
1129083
function (key, cb) {

            _util.buildQuery('events', {event_key: key}, function (error, data) {

                return cb(error, data);

            });

        }
304322
def _check_cb(cb_):
    '''
    
    '''
    if cb_ is not None:
        if hasattr(cb_, '__call__'):
            return cb_
        else:
            log.error('log_callback is not callable, ignoring')
    return lambda x: x
5631
function cb (err) {
    if (cb.done) return
    cb.done = true
    if (err) {
      log.warn('install', 'got an error, rolling back install')
      // roll-back the install if anything went wrong
      gyp.commands.remove([ release.versionDir ], function () {
        callback(err)
      })
    } else {
      callback(null, release.version)
    }
  }
972738
function version(cb) {

  function _cb(err, result, response) {
    if (err) {
      cb(err);
    } else if (response.headers['x-jenkins']) {
      cb(null, response.headers['x-jenkins']);
    } else {
      cb(new Error(text.__('Not a Jenkins server')));
    }
  }
  this.remoteAccessApi.headJenkins(_cb);
}
702234
public static Handler newHandler(Handler original, Handler.Callback callback) {
        return new Handler(original.getLooper(), callback);
    }
93470
function crumbIssuer(jenkins, callback) {
  jenkins.crumbIssuer.get(function(err, data) {
    if (err) return callback(err);
    if (!data || !data.crumbRequestField || !data.crumb) {
      return callback(new Error('Failed to get crumb'));
    }

    callback(null, {
      headerName: data.crumbRequestField,
      headerValue: data.crumb,
    });
  });
}
1310855
public <V> V execute(RedisCallback<V> cb) {
        Jedis jedis = jedisPool.getResource();
        boolean success = true;
        try {
            return cb.execute(jedis);
        } catch (JedisException e) {
            success = false;
            if (jedis != null) {
                jedisPool.returnBrokenResource(jedis);
            }
            throw e;
        } finally {
            if (success) {
                jedisPool.returnResource(jedis);
            }
        }
    }
1003524
function jobCallback(job, worker, index) {

    // as long as we have urls that we want to crawl we execute the job
    var url = pages[index];
    if (index < pages.length) {

        // the first argument contains the data which is passed to the worker
        // the second argument is a callback which is called when the job is executed
        job({
            url : url,
            id : index
        }, function(err) {
            // Lets log if it worked
            if (err) {
                console.log('There were some problems for url ' + url + ': ' + err.message);
            } else {
                console.log('DONE: ' + url + '(' + index + ')');
            }
        });
    } else {
        // if we have no more jobs, we call the function job with null
        job(null);
    }
}
134138
function(args, options, callback) {
            // Get the query and parameters, and remove the extraneous
            // search parameter
            var query = options.search;
            var params = options;
            delete params.search;

            // Create the job
            this.service.jobs().create(query, params, function(err, job) {
                if (err) {
                    callback(err);
                    return;
                }
                
                console.log("Created job " + job.sid);
                callback(null, job);
            });
        }
884927
function EventHandlerQueue (status, job){
        console.log ("#%d- Queue Status=%s DevId=%s Command=%s JobReq=%d Retry=%d", count, status, job.devId, job.command, job.request, job.retry);
    }
882442
function download(url, dest, cb) {
  var reportError = function(err) {
    var timeoutMessge;

    if (err.code === 'ETIMEDOUT') {
      if (err.connect === true) {
        // timeout is hit while your client is attempting to establish a connection to a remote machine
        timeoutMessge = 'Timed out attemping to establish a remote connection';
      } else {
        timeoutMessge = 'Timed out whilst downloading the prebuilt binary';
        // occurs any time the server is too slow to send back a part of the response
      }

    }
    cb(['Cannot download "', url, '": ', eol, eol,
      typeof err.message === 'string' ? err.message : err, eol, eol,
      timeoutMessge ? timeoutMessge + eol + eol : timeoutMessge,
      'Hint: If github.com is not accessible in your location', eol,
      '      try setting a proxy via HTTP_PROXY, e.g. ', eol, eol,
      '      export HTTP_PROXY=http://example.com:1234',eol, eol,
      'or configure npm proxy via', eol, eol,
      '      npm config set proxy http://example.com:8080'].join(''));
  };

  var successful = function(response) {
    return response.statusCode >= 200 && response.statusCode < 300;
  };

  console.log('Downloading binary from', url);

  try {
    request(url, downloadOptions(), function(err, response, buffer) {
      if (err) {
        reportError(err);
      } else if (!successful(response)) {
        reportError(['HTTP error', response.statusCode, response.statusMessage].join(' '));
      } else {
        console.log('Download complete');

        if (successful(response)) {
          fs.createWriteStream(dest)
            .on('error', cb)
            .end(buffer, cb);
        } else {
          cb();
        }
      }
    })
    .on('response', function(response) {
      var length = parseInt(response.headers['content-length'], 10);
      var progress = log.newItem('', length);

      // The `progress` is true by default. However if it has not
      // been explicitly set it's `undefined` which is considered
      // as far as npm is concerned.
      if (process.env.npm_config_progress === 'true') {
        log.enableProgress();

        response.on('data', function(chunk) {
          progress.completeWork(chunk.length);
        })
        .on('end', progress.finish);
      }
    });
  } catch (err) {
    cb(err);
  }
}
1345384
function () {
        const cronJobsToStart = _getNamesOfCronJobsToStart();
        if (!cronJobsToStart && _shouldStartCrons() && Shared.isDbConnectionAvailable() === true) {
            return CronJobManagerJob.startListening().then(function () {
                Logger.tag('Cron').info('Cron Job Manager is started. Starting all available cron jobs');
                return Q();
            }, function (err) {
                Logger.tag('Cron').error('Error starting Cron Job Manager ');
                return Q.reject(err);
            });
        } else if (cronJobsToStart && _shouldStartCrons()) {

            Logger.tag('Cron').info('Starting specific cron jobs "' + cronJobsToStart.join(', ') + '"');

            try {
                const cronJobs = Shared.cronModules(cronJobsToStart);
                let promises = [];
                for (let cron of cronJobs) {
                    // Set force run config
                    cron.forceRun = true;
                    promises.push(cron.worker(cron, cron));
                }
                return Q.all(promises)
                    .then(() => process.exit())
                    .catch(() => process.exit(1));
            } catch (err) {
                process.exit(1);
            }
        } else {
            Logger.tag('Cron').warn('Cron Manager is disabled for this environment.');
            return Q();
        }
    }
376116
function( url, cb ) {
		var xhr = new window.XMLHttpRequest();
		if ( "withCredentials" in xhr ) {
			xhr.open( "GET", url, true );
		} else if ( typeof window.XDomainRequest !== "undefined" ) { //IE
			xhr = new window.XDomainRequest();
			xhr.open( "GET", url );
		}
		if( cb ){
			xhr.onload = cb;
		}
		xhr.send();
		return xhr;
	}
1133239
function getMongooseConnection(mongoDbUrl, logger, cb) {
  logger.debug("creating mongoose connection for data_source_update job", {mongoDbUrl: mongoDbUrl});
  var mongooseConnection = mongoose.createConnection(mongoDbUrl);
  return cb(undefined, mongooseConnection);
}