"command=FINALIZE&media_id=601413451156586496"
437287
private UploadedMedia uploadMediaChunkedFinalize(long mediaId) throws TwitterException {
		int tries = 0;
		int maxTries = 20;
		int lastProgressPercent = 0;
		int currentProgressPercent = 0;
		UploadedMedia uploadedMedia = uploadMediaChunkedFinalize0(mediaId);
		while (tries < maxTries) {
			if(lastProgressPercent == currentProgressPercent) {
				tries++;
			}
			lastProgressPercent = currentProgressPercent;
			String state = uploadedMedia.getProcessingState();
			if (state.equals("failed")) {
				throw new TwitterException("Failed to finalize the chuncked upload.");
			}
			if (state.equals("pending") || state.equals("in_progress")) {
				currentProgressPercent = uploadedMedia.getProgressPercent();
				int waitSec = Math.max(uploadedMedia.getProcessingCheckAfterSecs(), 1);
				logger.debug("Chunked finalize, wait for:" + waitSec + " sec");
				try {
					Thread.sleep(waitSec * 1000);
				} catch (InterruptedException e) {
					throw new TwitterException("Failed to finalize the chuncked upload.", e);
				}
			}
			if (state.equals("succeeded")) {
				return uploadedMedia;
			}
			uploadedMedia = uploadMediaChunkedStatus(mediaId);
		} 
		throw new TwitterException("Failed to finalize the chuncked upload, progress has stopped, tried " + tries+1 + " times.");
	}
1357137
def finalize(self, result):
        
        runtime = int(time.time() * 1000) - self.execution_start_time
        self.testcase_manager.update_execution_data(self.execution_guid,
                                                    runtime)
1129721
function finalizeMeasurement(id) {
        if (activeTests[id.id]) {
            delete activeTests[id.id];
        }

        if (updatableTests[id.id]) {
            delete updatableTests[id.id];
        }
    }
91681
@Override
    public ManagedProcess waitForExitMaxMsOrDestroy(long maxWaitUntilDestroyTimeout)
            throws ManagedProcessException {
        waitForExitMaxMs(maxWaitUntilDestroyTimeout);
        if (isAlive()) {
            logger.info("Process didn't exit within max. {}ms, so going to destroy it now: {}",
                    maxWaitUntilDestroyTimeout, getProcLongName());
            destroy();
        }
        return this;
    }
893254
public synchronized void removeCommand(final CommandImpl command) throws DevFailed {
        if (!command.getName().equalsIgnoreCase(INIT_CMD)) {
            pollingManager.removeCommandPolling(command.getName());
            commandList.remove(command);
        }

    }
966000
public void command_factory()
	{
		command_list.addElement(new DevRestartCmd(
					"DevRestart",
					Tango_DEV_STRING,
					Tango_DEV_VOID,
					"Device name"));
		command_list.addElement(new RestartServerCmd(
					"RestartServer",
					Tango_DEV_VOID,
					Tango_DEV_VOID));
		command_list.addElement(new QueryClassCmd(
					"QueryClass",
					Tango_DEV_VOID,
					Tango_DEVVAR_STRINGARRAY,
					"Device server class(es) list"));
		command_list.addElement(new QueryDeviceCmd(
					"QueryDevice",
					Tango_DEV_VOID,
					Tango_DEVVAR_STRINGARRAY,
					"Device server device(s) list"));
		command_list.addElement(new KillCmd(
					"Kill",
					Tango_DEV_VOID,
					Tango_DEV_VOID));
		command_list.addElement(new AddLoggingTargetCmd(
					"AddLoggingTarget",
					Tango_DEVVAR_STRINGARRAY,
					Tango_DEV_VOID,
					"Str[i]=Device-name - Str[i+1]=target_type::target_name"));
		command_list.addElement(new RemoveLoggingTargetCmd(
					"RemoveLoggingTarget",
					Tango_DEVVAR_STRINGARRAY,
					Tango_DEV_VOID,
					"Str[i]=Device-name - Str[i+1]=target_type::target_name"));
		command_list.addElement(new GetLoggingTargetCmd("GetLoggingTarget",
					Tango_DEV_STRING,
					Tango_DEVVAR_STRINGARRAY,
					"Device name",
					"Logging target list"));
		command_list.addElement(new SetLoggingLevelCmd(
					"SetLoggingLevel",
					Tango_DEVVAR_LONGSTRINGARRAY,
                    Tango_DEV_VOID,
                    "Lg[i]=Logging level. Str[i]=Device name."));
		command_list.addElement(new GetLoggingLevelCmd(
					"GetLoggingLevel",
					Tango_DEVVAR_STRINGARRAY,
                    Tango_DEVVAR_LONGSTRINGARRAY,
                    "Device list",
                    "Lg[i]=Logging level. Str[i]=Device name."));
		command_list.addElement(new StopLoggingCmd(
					"StopLogging",
					Tango_DEV_VOID,
					Tango_DEV_VOID));
		command_list.addElement(new StartLoggingCmd(
					"StartLogging",
					Tango_DEV_VOID,
					Tango_DEV_VOID));

		// Now, commands related to polling
		command_list.addElement(new PolledDeviceCmd(
					"PolledDevice",
					Tango_DEV_VOID,
					Tango_DEVVAR_STRINGARRAY,
					"Polled device name list"));
		command_list.addElement(new DevPollStatusCmd(
					"DevPollStatus",
					Tango_DEV_STRING,
					Tango_DEVVAR_STRINGARRAY,
					"Device name",
					"Device polling status"));

		String	msg = "Lg[0]=Upd period. Str[0]=Device name. Str[1]=Object type. Str[2]=Object name";
		command_list.addElement(new AddObjPollingCmd(
					"AddObjPolling",
					Tango_DEVVAR_LONGSTRINGARRAY,
					Tango_DEV_VOID,
					msg));
						    
		command_list.addElement(new UpdObjPollingPeriodCmd(
					"UpdObjPollingPeriod",
					Tango_DEVVAR_LONGSTRINGARRAY,
					Tango_DEV_VOID,
					msg));

		msg = "Lg[0]=Upd period. Str[0]=Device name. Str[1]=Object type. Str[2]=Object name";
		command_list.addElement(new RemObjPollingCmd(
					"RemObjPolling",
					Tango_DEVVAR_STRINGARRAY,
					Tango_DEV_VOID,
					msg));
						    
		command_list.addElement(new StopPollingCmd(
					"StopPolling",
					Tango_DEV_VOID,
					Tango_DEV_VOID));
						  
		command_list.addElement(new StartPollingCmd(
					"StartPolling",
					Tango_DEV_VOID,
					Tango_DEV_VOID));
}
713523
function bin(argv) {
  // setup config
  var config = require('../config/config.js')

  program
  .option('-d, --database <database>', 'Database')
  .parse(argv)

  var defaultDatabase = 'media'

  config.database = program.database || config.database || defaultDatabase
  var url = process.argv[2] || 'https://www.reddit.com/r/perfectloops/top/?sort=top&t=all&count=25&after=t3_4j0v4f'

  qpm_media.getLastSeen(function(err, ret){
    if (err) {
      console.error(err)
    } else {
      console.log(ret[0][0].uri);
    }
  })


}
365313
def _finalize(self, dry_run=False):
        
        for rmfile in self.files.temp_files:
            if dry_run:
                print("remove %s" % rmfile)
            else:
                os.remove(rmfile)
        for gzfile in self.files.gzip_files:
            if dry_run:
                # print ("gzip %s" % gzfile)
                pass
            else:
                os.system('gzip -9 %s' % gzfile)
969562
function final(err,response){
  			if(err){$scope.errmsg = "Server error, please try again.";console.log({error:err})}
  			if(response){
  				//console.log(response);
  				$scope.smod = false;
  				delete $rootScope.mdb.sqls[$scope.savecsql.queryname]
  				delete $rootScope.mdb.esqls[$scope.savecsql.queryname]
  				var newrec = angular.copy($scope.csql)
  				$rootScope.mdb.esqls[$scope.csql.queryname] = newrec;
  				newrec.dbs   = newrec.db;
  				newrec.inuse = false;
  				$scope.csql.inuse = false;
  				$scope.runtestmsg = "";
  				$rootScope.mdb.queries.forEach(function(item){
  					if (item.id == $scope.csql.id){
  						item.queryname = $scope.csql.queryname;
  						item.inuse = false;
  						
  						$scope.qsel(item);
  					};
  				});
  			}
  		}
432008
function command(os) {
  var z = 'ffmpeg';
  var os = os||[];
  for(var o of os) {
    var o = o||{};
    for(var k in o) {
      if(o[k]==null) continue;
      if(k==='stdio') continue;
      if(k==='o' || k==='outfile') z += ` "${o[k]}"`;
      else if(typeof o[k]==='boolean') z += o[k]? ` -${k}`:'';
      else z += ` -${k} ${JSON.stringify(o[k])}`;
    }
  }
  return z;
}
183581
def _finalize_write(self):
        ''

        # Make sure we have written the header
        if not self._done_header:
            self._write_header()

        # Write the remaining decrypted part to disk
        block = self._crypto.encrypt(self._decrypted_buffer)
        self._decrypted = ''
        self._fp.write(block)
        self._checksumer.update(block)

        # Write the final checksum
        self._fp.write(self._checksumer.digest())
        self._valid = True
429581
function cmdProcess(file, flow, command, startFn, doneFn){
  var packStartTime = new Date;
  var fconsole = flow.console;
  var gcc;

  fconsole.log('Init compression for ' + file.relOutputFilename);
  gcc = exec(
    command, {
      maxBuffer: 10 * 1024 * 1024
    }, function(error, stdout, stderr){
      stderr = String(stderr || '').replace(/^The compiler is waiting for input via stdin\.\r?\n/, '');

      if (stderr)
      {
        var errorMsg;

        if (stderr.match(/^stdin:(\d+):\s+(.+)/))
        {
          var CHARS = 40;
          var lines = stderr.split(/\r\n?|\n\r?/);
          var m = (lines[2] || '').match(/^\s*/);
          var pos = (m ? m[0].length : 0);
          var left = Math.min(pos, CHARS);

          errorMsg =
            lines[0] + '\n' +
            (pos > CHARS ? '...' : '') +
            lines[1].substr(pos - left, CHARS) +
            lines[1].substr(pos, CHARS) +
            (pos + CHARS < stderr.length ? '...' : '') + '\n' +
            repeat(' ', left + (pos > CHARS ? 3 : 0)) + '^';
        }
        else
          errorMsg = stderr.length < 256
            ? stderr
            : stderr.substr(0, 128) + '...' + stderr.substr(stderr.length - 128);

        flow.warn({
          fatal: true,
          message:
            file.relOutputFilename + ' compression error:\n' +
            errorMsg
        });

        return doneFn();
      }

      fconsole.log(file.relOutputFilename + ' compressed in ' + ((new Date - packStartTime) / 1000).toFixed(3) + 's');
      if (error !== null)
        fconsole.log('exec error: ' + error);
      else
        file.outputContent = stdout.replace(/;[\r\n\s]*$/, '');

      doneFn();
    }
  );

  startFn();
  gcc.stdin.on('error', function(error){
    flow.warn({
      fatal: true,
      message:
        'Pack command: `' + command + '`\n' +
        error
    });
  });
  gcc.stdin.write(file.outputContent);
  gcc.stdin.end();
}
1280952
public void finalizeReplicaSync(int partitionId, int replicaIndex, ServiceNamespace namespace, long[] versions) {
        PartitionReplicaVersions replicaVersion = replicaVersions[partitionId];
        replicaVersion.clear(namespace);
        replicaVersion.set(namespace, versions, replicaIndex);
        clearReplicaSyncRequest(partitionId, namespace, replicaIndex);
    }
1157941
@Override
    @Transactional
    public void finalizeRestores() {
        log.debug("Running finalize restores...");
        List<Restoration> completedRestores =
            restoreRepo.findByStatus(RestoreStatus.RESTORATION_COMPLETE);

        for (Restoration restoration : completedRestores) {
            Date expirationDate = restoration.getExpirationDate();
            if (expirationDate.before(new Date())) { // Only continue if expired
                DuracloudEndPointConfig destination = restoration.getDestination();
                ContentStore store =
                    storeClientHelper.create(destination,
                                             bridgeConfig.getDuracloudUsername(),
                                             bridgeConfig.getDuracloudPassword());
                try {
                    String spaceId = destination.getSpaceId();
                    Iterator<String> it = store.getSpaceContents(spaceId);
                    if (!it.hasNext()) { // if space is empty
                        // Call DuraCloud to remove space
                        log.info("Deleting expired restoration space: " + spaceId +
                                 " at host: " + destination.getHost());
                        store.deleteSpace(spaceId);

                        // Update restore status
                        validateAndSet(restoration,
                                       RestoreStatus.RESTORATION_EXPIRED,
                                       "Restoration expired");
                        restoration = save(restoration);
                        log.info("Transition of restore " +
                                 restoration.getRestorationId() +
                                 " to expired state completed successfully");

                        // Add history event
                        String history =
                            "[{'" + RESTORE_ACTION_TITLE + "':'" + RESTORE_ACTION_EXPIRED + "'}," +
                            "{'" + RESTORE_ID_TITLE + "':'" + restoration.getRestorationId() + "'}]";
                        snapshotManager.updateHistory(restoration.getSnapshot(), history);
                    }
                } catch (Exception e) {
                    log.error("Failed to transition restore " +
                              restoration.getRestorationId() +
                              " to expired state due to: " + e.getMessage());
                }
            }
        }
    }
726715
private long finalizeFlv() {
        long bytesTransferred = 0L;
        if (!finalized.get()) {
            log.debug("Finalizing {}", filePath);
            try {
                // read file info if it exists
                File tmpFile = new File(filePath + ".info");
                if (tmpFile.exists()) {
                    int[] info = readInfoFile(tmpFile);
                    if (audioCodecId == -1 && info[0] > 0) {
                        audioCodecId = info[0];
                    }
                    if (videoCodecId == -1 && info[1] > 0) {
                        videoCodecId = info[1];
                    }
                    if (duration == 0 && info[2] > 0) {
                        duration = info[2];
                    }
                    if (audioDataSize == 0 && info[3] > 0) {
                        audioDataSize = info[3];
                    }
                    if (soundRate == 0 && info[4] > 0) {
                        soundRate = info[4];
                    }
                    if (soundSize == 0 && info[5] > 0) {
                        soundSize = info[5];
                    }
                    if (!soundType && info[6] > 0) {
                        soundType = true;
                    }
                    if (videoDataSize == 0 && info[7] > 0) {
                        videoDataSize = info[7];
                    }
                } else {
                    log.debug("Flv info file not found");
                }
                tmpFile = null;
                // write the file header
                writeHeader();
                log.debug("Pos post header: {}", fileChannel.position());
                // write the metadata with the final duration
                writeMetadataTag(duration * 0.001d, videoCodecId, audioCodecId);
                log.debug("Pos post meta: {}", fileChannel.position());
                // create a transfer buffer
                ByteBuffer dst = ByteBuffer.allocate(1024);
                // when appending, read original stream data first and put it at the front
                if (append) {
                    Path prevFlv = Paths.get(filePath.replace(".flv", ".old"));
                    if (Files.exists(prevFlv)) {
                        log.debug("Found previous flv: {} offset: {}", prevFlv, appendOffset);
                        SeekableByteChannel prevChannel = Files.newByteChannel(prevFlv, StandardOpenOption.READ);
                        // skip the flv header, prev tag size, and possibly metadata
                        prevChannel.position(appendOffset);
                        int read = -1, wrote;
                        boolean showfirsttag = true;
                        do {
                            read = prevChannel.read(dst);
                            log.trace("Read: {} bytes", read);
                            if (read > 0) {
                                dst.flip();
                                // inspect the byte to make sure its a valid type
                                if (showfirsttag) {
                                    showfirsttag = false;
                                    dst.mark();
                                    log.debug("Tag type: {}", (dst.get() & 31));
                                    dst.reset();
                                }
                                wrote = fileChannel.write(dst);
                                log.trace("Wrote: {} bytes", wrote);
                                bytesTransferred += wrote;
                            }
                            dst.compact();
                        } while (read > 0);
                        dst.clear();
                        prevChannel.close();
                        // remove the previous flv
                        Files.deleteIfExists(prevFlv);
                        log.debug("Previous FLV bytes written: {} final position: {}", (bytesWritten + bytesTransferred), fileChannel.position());
                    } else {
                        log.warn("Previous flv to be appended was not found: {}", prevFlv);
                    }
                }
                // get starting position of the channel where latest stream data was written
                long pos = dataChannel.position();
                log.trace("Data available: {} bytes", pos);
                // set the data file the beginning 
                dataChannel.position(0L);
                // transfer / write data file into final flv
                int read = -1, wrote;
                do {
                    read = dataChannel.read(dst);
                    log.trace("Read: {} bytes", read);
                    if (read > 0) {
                        dst.flip();
                        wrote = fileChannel.write(dst);
                        log.trace("Wrote: {} bytes", wrote);
                        bytesTransferred += wrote;
                    }
                    dst.compact();
                } while (read > 0);
                dst.clear();
                dataChannel.close();
                // get final position
                long length = fileChannel.position();
                // close the file
                fileChannel.close();
                // close and remove the ser file if write was successful
                if (bytesTransferred > 0) {
                    if (!Files.deleteIfExists(Paths.get(filePath + ".info"))) {
                        log.warn("FLV info file not deleted");
                    }
                    if (!Files.deleteIfExists(Paths.get(filePath + ".ser"))) {
                        log.warn("FLV serial file not deleted");
                    }
                }
                log.debug("FLV bytes written: {} final position: {}", (bytesWritten + bytesTransferred), length);
            } catch (Exception e) {
                log.warn("Finalization of flv file failed; new finalize job will be spawned", e);
            } finally {
                finalized.compareAndSet(false, true);
                // check for post processors that may be available
                if (FLVWriter.flv != null) {
                    LinkedList<Class<IPostProcessor>> writePostProcessors = ((FLV) FLVWriter.flv).getWritePostProcessors();
                    if (writePostProcessors != null) {
                        for (Class<IPostProcessor> postProcessor : writePostProcessors) {
                            try {
                                addPostProcessor(postProcessor.newInstance());
                            } catch (Exception e) {
                                log.warn("Post processor: {} instance creation failed", postProcessor, e);
                            }
                        }
                    }
                }
                // run post process
                if (postProcessors != null) {
                    for (IPostProcessor postProcessor : postProcessors) {
                        log.debug("Execute: {}", postProcessor);
                        try {
                            // set properties that the post processor requires or may require
                            postProcessor.init(filePath);
                            // execute and block
                            executor.submit(postProcessor).get();
                        } catch (Throwable t) {
                            log.warn("Exception during post process on: {}", filePath, t);
                        }
                    }
                    postProcessors.clear();
                } else {
                    log.debug("No post processors configured");
                }
            }
        } else {
            log.trace("Finalization already completed");
        }
        return bytesTransferred;
    }
665790
def do_finalize(self):
		
		shutit_global.shutit_global_object.yield_to_draw()
		def _finalize(self):
			# Stop all the modules
			self.stop_all()
			# Finalize in reverse order
			self.log('PHASE: finalizing object ' + str(self), level=logging.DEBUG)
			# Login at least once to get the exports.
			for module_id in self.module_ids(rev=True):
				# Only finalize if it's thought to be installed.
				if self.is_installed(self.shutit_map[module_id]):
					self.login(prompt_prefix=module_id,command=shutit_global.shutit_global_object.bash_startup_command,echo=False)
					if not self.shutit_map[module_id].finalize(self):
						self.fail(module_id + ' failed on finalize', shutit_pexpect_child=self.get_shutit_pexpect_session_from_id('target_child').pexpect_child) # pragma: no cover
					self.logout(echo=False)
		_finalize(self)
691386
public function update_8006006() {
    $composer_json = $this->updater->getComposerJson();
    unset($composer_json['require-dev']['drush/drush']);
    $this->updater->writeComposerJson($composer_json);
  }