Run the sync.

        Confront the local and the remote directories and perform the needed changes.
325509
def run(self):
        """"""

        # Check if remote path is present
        try:
            self.sftp.stat(self.remote_path)
        except FileNotFoundError as e:
            if self.create_remote_directory:
                self.sftp.mkdir(self.remote_path)
                self.logger.info(
                    "Created missing remote dir: '" + self.remote_path + "'")
            else:
                self.logger.error(
                    "Remote folder does not exists. "
                    "Add '-r' to create it if missing.")
                sys.exit(1)

        try:
            if self.delete:
                # First check for items to be removed
                self.check_for_deletion()

            # Now scan local for items to upload/create
            self.check_for_upload_create()
        except FileNotFoundError:
            # If this happens, probably the remote folder doesn't exist.
            self.logger.error(
                "Error while opening remote folder. Are you sure it does exist?")
            sys.exit(1)
747370
public void run()
   {
      for (;;)
      {
         boolean isIdle = false;
         if (mergeTasks.size() == 0)
         {
            mergerIdle.release();
            isIdle = true;
         }
         Merge task = (Merge)mergeTasks.remove();
         if (task == QUIT) // NOSONAR
         {
            mergerIdle.release();
            break;
         }
         if (isIdle)
         {
            try
            {
               mergerIdle.acquire();
            }
            catch (InterruptedException e)
            {
               Thread.interrupted();
               log.warn("Unable to acquire mergerIdle sync");
            }
         }

         log.debug("accepted merge request");

         // reset deleted documents
         deletedDocuments.clear();

         // get readers
         String[] names = new String[task.indexes.length];
         for (int i = 0; i < task.indexes.length; i++)
         {
            names[i] = task.indexes[i].name;
         }
         try
         {
            log.debug("create new index");
            PersistentIndex index = multiIndex.getOrCreateIndex(null);
            boolean success = false;
            try
            {

               log.debug("get index readers from MultiIndex");
               IndexReader[] readers = multiIndex.getIndexReaders(names, this);
               try
               {
                  // do the merge
                  long time = System.currentTimeMillis();
                  index.addIndexes(readers);
                  time = System.currentTimeMillis() - time;
                  int docCount = 0;
                  for (int i = 0; i < readers.length; i++)
                  {
                     docCount += readers[i].numDocs();
                  }
                  if (log.isDebugEnabled())
                  {
                     log.debug("merged " + docCount + " documents in " + time + " ms into " + index.getName() + ".");
                  }
               }
               finally
               {
                  for (int i = 0; i < readers.length; i++)
                  {
                     try
                     {
                        Util.closeOrRelease(readers[i]);
                     }
                     catch (IOException e)
                     {
                        log.warn("Unable to close IndexReader: " + e);
                     }
                  }
               }

               // inform multi index
               // if we cannot get the sync immediately we have to quit
               if (!indexReplacement.attempt(0))
               {
                  log.debug("index merging canceled");
                  // if index not passed to multiIndex, then it will never be closed
                  index.close();
                  break;
               }
               try
               {
                  log.debug("replace indexes");
                  multiIndex.replaceIndexes(names, index, deletedDocuments);
               }
               finally
               {
                  indexReplacement.release();
               }

               success = true;

            }
            finally
            {
               if (!success)
               {
                  // delete index
                  log.debug("deleting index " + index.getName());
                  multiIndex.deleteIndex(index);
               }
            }
         }
         catch (Throwable e) //NOSONAR
         {
            log.error("Error while merging indexes: ", e);
         }
      }
      if (log.isDebugEnabled())
      {
         log.debug("IndexMerger terminated");
      }
   }
153775
def run (self):
        """"""
        if self.all:
            # remove share directory
            directory = os.path.join("build", "share")
            if os.path.exists(directory):
                remove_tree(directory, dry_run=self.dry_run)
            else:
                log.warn("'%s' does not exist -- can't clean it", directory)
        clean.run(self)
1054617
def run():
    """"""
    _parser_options()
    set_verbose(args["verbose"])
    
    if _check_global_settings():
        _load_db()
    else:
        exit(-1)

    #Check the server configuration against the script arguments passed in.
    _setup_server()

    if args["rollback"]:
        _server_rollback()
        okay("The server rollback appears to have been successful.")
        exit(0)

    _server_enable()    
    _list_repos()
    _handle_install()
    
    #This is the workhorse once a successful installation has happened.
    _do_cron()
304668
def run(self, **options):
        """"""
        if not self.is_setup:
            self.setup()

        if self.twisted:
            self.run_with_twisted(**options)
        elif self.gunicorn:
            self.run_with_gunicorn(**options)
        else:
            self.run_with_werkzeug(**options)
50931
def sync(self, localpath, href, exclude=None, block=True):
        
        logger.info(u("sync: %s %s") % (localpath, href))
        try:
            localpath = _(localpath)
            href = remote(href)
            localRoot, localFolders, localFiles = next(os.walk(localpath))
            remoteFolders, remoteFiles = self.list(href)
            if remoteFiles is None or remoteFolders is None:
                remoteFiles = {}
                remoteFolders = {}
                self.mkdir(href)

            def norm(folder):
                path = os.path.join(href, _(folder))
                if path[len(path) - 1] != os.path.sep:
                    path += u("/")
                return path

            foldersToCreate = filter(
                lambda folderPath: folderPath not in remoteFolders,
                map(norm, localFolders)
            )
            apply_async("mkdir", lambda path: self.mkdir(path), foldersToCreate, self.limit)

            filesToSync = filter(
                lambda lFile: os.path.join(href, _(lFile)) not in remoteFiles,
                localFiles
            )
            fileArgs = [(os.path.join(localpath, f), os.path.join(href, f))
                        for f in filesToSync]
            apply_async("upload", lambda s, t: self.upload(s, t), fileArgs, self.limit)

            for folder in localFolders:
                localFolderPath = os.path.join(localpath, folder)
                remoteFolderPath = os.path.join(href, folder)
                if exclude:
                    bSync = exclude(localFolderPath, remoteFolderPath)
                else:
                    bSync = True
                if bSync:
                    apply_async(
                        "sync",
                        lambda localpath, href: self.sync(localpath, href, exclude, False),
                        [(localFolderPath, remoteFolderPath), ]
                    )
        except ConnectionException:
            raise
        except Exception:
            e = sys.exc_info()[1]
            logger.exception(e)
        if block:
            qWork.join()
396024
function() {
    var self = this
    self._shouldSyncFromOpts = true
    self.on('update', function() {
      if (self._shouldSyncFromOpts) self.trigger('sync')
      self._shouldSyncFromOpts = true
    })
  }
619906
void runAsync() {
        // Determine if a task is running. If so, record the fact we want to have it run again, otherwise reserve our spot.
        synchronized (this) {
            Exceptions.checkNotClosed(this.closed, this);
            if (this.running) {
                this.runAgain = true;
                return;
            }

            this.running = true;
        }

        // Execute the task.
        runInternal();
    }
160259
public function run() {
		$this->load_hooks();

		// Need to ensure these classes are activated here for hooks to fire.
		if ( $this->is_current_page( [ 'options.php', 'options-general.php', 'settings.php' ] ) ) {
			Singleton::get_instance( 'Install', $this )->run();
			Singleton::get_instance( 'Remote_Management', $this )->load_hooks();
		}
	}
1173444
def run(self):
        """"""
        with utils.ChangeDir(self.dirname):
            sys.path.insert(0, self.dirname)
            sys.argv[1:] = self.args
            runpy.run_module(self.not_suffixed(self.filename),
                             run_name='__main__',
                             alter_sys=True)
792555
def run(self):
        ""
        # load files from source directory
        files = self.get_files()

        # loop through each middleware
        for func in self.middleware:

            # call each one, ignoring return value
            func(files, self)

        # store and return the result
        self.files.update(files)
        return files
880451
def run(self):
        """"""
        while True:
            try:
                self.perform_iteration()
            except Exception:
                traceback.print_exc()
                pass

            time.sleep(ray_constants.REPORTER_UPDATE_INTERVAL_MS / 1000)
1310448
def run(self):
        """"""
        self.run_command('sdist')
        self.run_command('upload')
        os.system('git tag -a {0} -m \'version {0}\''.format(version))
        os.system('git push --tags')
1210539
public void run() {
    while (running) {
      try {
        LOG.info("FileFixer continuing to run...");
        doFindFiles();
      } catch (Exception e) {
        LOG.error(StringUtils.stringifyException(e));
      } catch (Error err) {
        LOG.error("Exiting after encountering " +
                    StringUtils.stringifyException(err));
        shutdown();
        throw err;
      }
      try {
        // Sleep before proceeding to fix more files.
        Thread.sleep(blockFixInterval);
      } catch (InterruptedException ie) {
        LOG.error("Encountering InturruptedException " +
                   StringUtils.stringifyException(ie));
      }
    }
  }
289913
def run_work(self):
    """"""
    if os.path.exists(LOCAL_EVAL_ROOT_DIR):
      sudo_remove_dirtree(LOCAL_EVAL_ROOT_DIR)
    self.run_attacks()
    self.run_defenses()
422854
public void run() {
        Runnable r = null;
        while (true) {
            // Try to drain the maximum capacity of thread-local items, checking
            // whether any were available
            if (workQueue.drainTo(internalQueue, threadLocalItems) == 0) {
                // block until a work item is available
                try {
                    internalQueue.offer(workQueue.take());
                } catch (InterruptedException ie) {
                    throw new Error(ie);
                }
            }
            // Execute all of the thread-local items
            while ((r = internalQueue.poll()) != null)
                r.run();
        }
    }
18416
public void sync() {

        if (isClosed) {
            return;
        }

        synchronized (fileStreamOut) {
            if (needsSync) {
                if (busyWriting) {
                    forceSync = true;

                    return;
                }

                try {
                    fileStreamOut.flush();
                    outDescriptor.sync();

                    syncCount++;
                } catch (IOException e) {
                    Error.printSystemOut("flush() or sync() error: "
                                         + e.toString());
                }

                needsSync = false;
                forceSync = false;
            }
        }
    }