text:
// <copyright file="FirefoxBinary.cs" company="WebDriver Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// </copyright>

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using OpenQA.Selenium.Firefox.Internal;

namespace OpenQA.Selenium.Firefox
{
    /// <summary>
    /// Represents the binary associated with Firefox.
    /// </summary>
    /// <remarks>The <see cref="FirefoxBinary"/> class is responsible for instantiating the
    /// Firefox process, and the operating system environment in which it runs.</remarks>
    public class FirefoxBinary
    {
        #region Constants
        private const string NoFocusLibraryName = "x_ignore_nofocus.so";
        #endregion

        #region Private members
        private Dictionary<string, string> extraEnv = new Dictionary<string, string>();
        private Executable executable;
        private Process process;
        private TimeSpan timeout = TimeSpan.FromSeconds(45);
        #endregion

        #region Constructors
        /// <summary>
        /// Initializes a new instance of the <see cref="FirefoxBinary"/> class.
        /// </summary>
        public FirefoxBinary() :
            this(null)
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="FirefoxBinary"/> class located at a specific file location.
        /// </summary>
        /// <param name="pathToFirefoxBinary">Full path and file name to the Firefox executable.</param>
        public FirefoxBinary(string pathToFirefoxBinary)
        {
            this.executable = new Executable(pathToFirefoxBinary);
        }
        #endregion

        #region Public properties
        /// <summary>
        /// Gets or sets the timeout (in milliseconds) to wait for command execution.
        /// </summary>
        [Obsolete("Timeouts should be expressed as a TimeSpan. Use the Timeout property instead")]
        public long TimeoutInMilliseconds
        {
            get { return Convert.ToInt64(this.Timeout.TotalMilliseconds); }
            set { this.Timeout = TimeSpan.FromMilliseconds(value); }
        }

        /// <summary>
        /// Gets or sets the timeout to wait for Firefox to be available for command execution.
        /// </summary>
        public TimeSpan Timeout
        {
            get { return this.timeout; }
            set { this.timeout = value; }
        }
        #endregion

        #region Support properties
        /// <summary>
        /// Gets the <see cref="Executable"/> associated with this <see cref="FirefoxBinary"/>.
        /// </summary>
        internal Executable BinaryExecutable
        {
            get { return this.executable; }
        }

        /// <summary>
        /// Gets a value indicating whether the current operating system is Linux.
        /// </summary>
        protected static bool IsOnLinux
        {
            get { return Platform.CurrentPlatform.IsPlatformType(PlatformType.Linux); }
        }

        /// <summary>
        /// Gets a <see cref="Dictionary{K, V}"/> containing string key-value pairs
        /// representing any operating system environment variables beyond the defaults.
        /// </summary>
        protected Dictionary<string, string> ExtraEnvironmentVariables
        {
            get { return this.extraEnv; }
        }
        #endregion

        /// <summary>
        /// Starts Firefox using the specified profile and command-line arguments.
        /// </summary>
        /// <param name="profile">The <see cref="FirefoxProfile"/> to use with this instance of Firefox.</param>
        /// <param name="commandLineArguments">The command-line arguments to use in starting Firefox.</param>
        [SecurityPermission(SecurityAction.Demand)]
        public void StartProfile(FirefoxProfile profile, params string[] commandLineArguments)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile", "profile cannot be null");
            }

            if (commandLineArguments == null)
            {
                commandLineArguments = new string[] { };
            }

            string profileAbsPath = profile.ProfileDirectory;
            this.SetEnvironmentProperty("XRE_PROFILE_PATH", profileAbsPath);
            this.SetEnvironmentProperty("MOZ_NO_REMOTE", "1");
            this.SetEnvironmentProperty("MOZ_CRASHREPORTER_DISABLE", "1"); // Disable Breakpad
            this.SetEnvironmentProperty("NO_EM_RESTART", "1"); // Prevent the binary from detaching from the console

            if (IsOnLinux && (profile.EnableNativeEvents || profile.AlwaysLoadNoFocusLibrary))
            {
                this.ModifyLinkLibraryPath(profile);
            }

            StringBuilder commandLineArgs = new StringBuilder();
            foreach (string commandLineArg in commandLineArguments)
            {
                commandLineArgs.Append(" ").Append(commandLineArg);
            }

            Process builder = new Process();
            builder.StartInfo.FileName = this.BinaryExecutable.ExecutablePath;
            builder.StartInfo.Arguments = commandLineArgs.ToString();
            builder.StartInfo.UseShellExecute = false;

            foreach (string environmentVar in this.extraEnv.Keys)
            {
                if (builder.StartInfo.EnvironmentVariables.ContainsKey(environmentVar))
                {
                    builder.StartInfo.EnvironmentVariables[environmentVar] = this.extraEnv[environmentVar];
                }
                else
                {
                    builder.StartInfo.EnvironmentVariables.Add(environmentVar, this.extraEnv[environmentVar]);
                }
            }

            this.BinaryExecutable.SetLibraryPath(builder);

            this.StartFirefoxProcess(builder);

            this.CopeWithTheStrangenessOfTheMac(builder);
        }

        /// <summary>
        /// Sets a variable to be used in the Firefox execution environment.
        /// </summary>
        /// <param name="propertyName">The name of the environment variable to set.</param>
        /// <param name="value">The value of the environment variable to set.</param>
        public void SetEnvironmentProperty(string propertyName, string value)
        {
            if (string.IsNullOrEmpty(propertyName) || value == null)
            {
                throw new WebDriverException(string.Format(CultureInfo.InvariantCulture, "You must set both the property name and value: {0}, {1}", propertyName, value));
            }

            if (this.extraEnv.ContainsKey(propertyName))
            {
                this.extraEnv[propertyName] = value;
            }
            else
            {
                this.extraEnv.Add(propertyName, value);
            }
        }

        /// <summary>
        /// Creates a named profile for Firefox.
        /// </summary>
        /// <param name="profileName">The name of the profile to create.</param>
        [SecurityPermission(SecurityAction.Demand)]
        public void CreateProfile(string profileName)
        {
            Process builder = new Process();
            builder.StartInfo.FileName = this.executable.ExecutablePath;
            builder.StartInfo.Arguments = "--verbose -CreateProfile " + profileName;
            builder.StartInfo.EnvironmentVariables.Add("MOZ_NO_REMOTE", "1");

            this.StartFirefoxProcess(builder);
        }

        /// <summary>
        /// Waits for the process to complete execution.
        /// </summary>
        [SecurityPermission(SecurityAction.Demand)]
        public void WaitForProcessExit()
        {
            this.process.WaitForExit();
        }

        /// <summary>
        /// Initializes the binary with the specified profile.
        /// </summary>
        /// <param name="profile">The <see cref="FirefoxProfile"/> to use to initialize the binary.</param>
        public void Clean(FirefoxProfile profile)
        {
            if (profile == null)
            {
                throw new ArgumentNullException("profile", "profile cannot be null");
            }

            this.StartProfile(profile, "-silent");
            try
            {
                this.WaitForProcessExit();
            }
            catch (ThreadInterruptedException e)
            {
                throw new WebDriverException("Thread was interrupted", e);
            }
        }

        /// <summary>
        /// Stops the execution of this <see cref="FirefoxBinary"/>, terminating the process if necessary.
        /// </summary>
        [SecurityPermission(SecurityAction.Demand)]
        public void Quit()
        {
            // Suicide watch: First,  a second to see if the process will die on
            // it's own (we will likely have asked the process to kill itself just
            // before calling this method).
            if (this.process != null)
            {
                if (!this.process.HasExited)
                {
                    System.Threading.Thread.Sleep(1000);
                }

                // Murder option: The process is still alive, so kill it.
                if (!this.process.HasExited)
                {
                    this.process.Kill();
                }

                this.process.Dispose();
                this.process = null;
            }
        }

        /// <summary>
        /// Returns a <see cref="System.String">String</see> that represents the current <see cref="System.Object">Object</see>.
        /// </summary>
        /// <returns>A <see cref="System.String">String</see> that represents the current <see cref="System.Object">Object</see>.</returns>
        public override string ToString()
        {
            return "FirefoxBinary(" + this.executable.ExecutablePath + ")";
        }

        /// <summary>
        /// Starts the Firefox process.
        /// </summary>
        /// <param name="builder">A <see cref="Process"/> object used to start Firefox.</param>
        [SecurityPermission(SecurityAction.Demand)]
        protected void StartFirefoxProcess(Process builder)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder", "builder cannot be null");
            }

            this.process = builder;
            this.process.Start();
        }

        private static void Sleep(int timeInMilliseconds)
        {
            try
            {
                Thread.Sleep(timeInMilliseconds);
            }
            catch (ThreadInterruptedException e)
            {
                throw new WebDriverException("Thread was interrupted", e);
            }
        }

        private static string ExtractAndCheck(FirefoxProfile profile, string noFocusSoName, string libraryPath32Bit, string libraryPath64Bit)
        {
            //// 1. Extract x86/x_ignore_nofocus.so to profile.getLibsDir32bit
            //// 2. Extract amd64/x_ignore_nofocus.so to profile.getLibsDir64bit
            //// 3. Create a new LD_LIB_PATH string to contain:
            ////    profile.getLibsDir32bit + ":" + profile.getLibsDir64bit
            List<string> pathsSet = new List<string>();
            pathsSet.Add(libraryPath32Bit);
            pathsSet.Add(libraryPath64Bit);

            StringBuilder builtPath = new StringBuilder();

            foreach (string path in pathsSet)
            {
                string outSoPath = Path.Combine(profile.ProfileDirectory, path);
                string file = Path.Combine(outSoPath, noFocusSoName);

                string resourceName = string.Format(CultureInfo.InvariantCulture, "WebDriver.FirefoxNoFocus.{0}.dll", path);
                Assembly executingAssembly = Assembly.GetExecutingAssembly();

                List<string> resourceNames = new List<string>(executingAssembly.GetManifestResourceNames());
                if (resourceNames.Contains(resourceName))
                {
                    Stream libraryStream = executingAssembly.GetManifestResourceStream(resourceName);

                    Directory.CreateDirectory(outSoPath);
                    using (FileStream outputStream = File.Create(file))
                    {
                        byte[] buffer = new byte[1000];
                        int bytesRead = libraryStream.Read(buffer, 0, buffer.Length);
                        while (bytesRead > 0)
                        {
                            outputStream.Write(buffer, 0, bytesRead);
                            bytesRead = libraryStream.Read(buffer, 0, buffer.Length);
                        }
                    }

                    libraryStream.Close();
                }

                if (!File.Exists(file))
                {
                    throw new WebDriverException("Could not locate " + path + ": "
                                                 + "native events will not work.");
                }

                builtPath.Append(outSoPath).Append(Path.PathSeparator);
            }

            return builtPath.ToString();
        }

        private void ModifyLinkLibraryPath(FirefoxProfile profile)
        {
            // Extract x_ignore_nofocus.so from x86, amd64 directories inside
            // the jar into a real place in the filesystem and change LD_LIBRARY_PATH
            // to reflect that.
            string existingLdLibPath = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");

            // The returned new ld lib path is terminated with ':'
            string newLdLibPath = ExtractAndCheck(profile, NoFocusLibraryName, "x86", "amd64");
            if (!string.IsNullOrEmpty(existingLdLibPath))
            {
                newLdLibPath += existingLdLibPath;
            }

            this.SetEnvironmentProperty("LD_LIBRARY_PATH", newLdLibPath);

            // Set LD_PRELOAD to x_ignore_nofocus.so - this will be taken automagically
            // from the LD_LIBRARY_PATH
            this.SetEnvironmentProperty("LD_PRELOAD", NoFocusLibraryName);
        }

        [SecurityPermission(SecurityAction.Demand)]
        private void CopeWithTheStrangenessOfTheMac(Process builder)
        {
            if (Platform.CurrentPlatform.IsPlatformType(PlatformType.Mac))
            {
                // On the Mac, this process sometimes dies. Check for this, put in a decent sleep
                // and then attempt to restart it. If this doesn't work, then give up

                // TODO(simon): Why is this happening? Firefox 2 never seemed to suffer this
                try
                {
                    System.Threading.Thread.Sleep(300);
                    if (this.process.ExitCode == 0)
                    {
                        return;
                    }

                    // Looks like it's gone wrong.
                    // TODO(simon): This is utterly bogus. We should do something far smarter
                    System.Threading.Thread.Sleep(10000);

                    this.StartFirefoxProcess(builder);
                }
                catch (ThreadStateException)
                {
                    // Excellent, we've not creashed.
                }

                // Ensure we're okay
                try
                {
                    Sleep(300);

                    if (this.process.ExitCode == 0)
                    {
                        return;
                    }

                    StringBuilder message = new StringBuilder("Unable to start firefox cleanly.\n");
                    message.Append("Exit value: ").Append(this.process.ExitCode.ToString(CultureInfo.InvariantCulture)).Append("\n");
                    message.Append("Ran from: ").Append(builder.StartInfo.FileName).Append("\n");
                    throw new WebDriverException(message.ToString());
                }
                catch (ThreadStateException)
                {
                    // Woot!
                }
            }
        }
    }
}


text:
<!DOCTYPE html>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>TorrentClientSignalWithFront class - hetimatorrent.client library - Dart API</title>

    <base href="..">

    <link href='https://fonts.googleapis.com/css?family=Source+Code+Pro|Roboto:500,400italic,300,400' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="static-assets/prettify.css">
    <link rel="stylesheet" href="static-assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="static-assets/styles.css">

    <meta name="description" content="API docs for the TorrentClientSignalWithFront class from the hetimatorrent.client library, for the Dart programming language.">
    <link rel="icon" href="static-assets/favicon.png">

            <button id="sidenav-left-toggle" type="button"> </button>

hetimatorrent

hetimatorrent.client

TorrentClientSignalWithFront

TorrentClientSignalWithFront

hetimatorrent

hetimatorrent.client

TorrentClientSignalWithFront

class
 TorrentClientSignalWithFront

Properties

Constructors

hetimatorrent

hetimatorrent.client

Classes

TMessageBitfield

TMessageCancel

TMessageChoke

TMessageHandshake

TMessageHave

TMessageInterested

TMessageKeepAlive

TMessageNotInterested

TMessageNull

TMessagePiece

TMessagePort

TMessageRequest

TMessageUnchoke

TorrenAIEmpty

TorrentAI

TorrentAIBasic

TorrentAIChokeTest

TorrentAIChokeTestResult

TorrentClient

TorrentClientFront

TorrentClientFrontNerve

TorrentClientManager

TorrentClientMessage

TorrentClientPeerInfo

TorrentClientPeerInfoBasic

TorrentClientPeerInfoEmpty

TorrentClientPeerInfos

TorrentClientSignal

TorrentClientSignalWithFront

TorrentClientSignalWithPeerInfo

TorrentMessage

Not documented.

Extends

Object

TorrentClientSignal

TorrentClientSignalWithFront

Properties

                TorrentClientFront
                front

        read-only

                int
                id

        read-only, inherited

                int
                reason

        read-only, inherited

                int
                v

        read-only

Constructors

                TorrentClientSignalWithFront(TorrentClientFront front, int id, int reason, String message, [int v = 0])

Methods

                  toString(<wbr>)
                      →
                      String

                    inherited

                  Returns a string representation of this object.

TorrentClientSignalWithFront

Properties

front

id

reason

v

Constructors

TorrentClientSignalWithFront

Methods

toString

                  hetimatorrent 0.0.1 api docs

                •

                •

                  cc license

redpajama_set_name: RedPajamaGithub


text:
<?php
error_reporting(-1);

$file = __DIR__ . '/../vendor/autoload.php';
if (!file_exists($file)) {
    throw new RuntimeException('Install dependencies to run test suite.');
}

$loader = require $file;

$loader->add('AMQPy\Helpers', __DIR__);
$loader->add('AMQPy\Tests', __DIR__);


text:
const test = require('tap').test;
const Clock = require('../../src/io/clock');
const Runtime = require('../../src/engine/runtime');

test('spec', t => {
    const rt = new Runtime();
    const c = new Clock(rt);

    t.type(Clock, 'function');
    t.type(c, 'object');
    t.type(c.projectTimer, 'function');
    t.type(c.pause, 'function');
    t.type(c.resume, 'function');
    t.type(c.resetProjectTimer, 'function');
    t.end();
});

test('cycle', t => {
    const rt = new Runtime();
    const c = new Clock(rt);

    t.ok(c.projectTimer() <= 0.1);
    setTimeout(() => {
        c.resetProjectTimer();
        setTimeout(() => {
            // The timer shouldn't advance until all threads have been stepped
            t.ok(c.projectTimer() === 0);
            c.pause();
            t.ok(c.projectTimer() === 0);
            c.resume();
            t.ok(c.projectTimer() === 0);
            t.end();
        }, 100);
    }, 100);
    rt._step();
    t.ok(c.projectTimer() > 0);
});


text:
ActiveRecord::Schema.define(:version => 20131224090934) do

  create_table "associate_maintainers", :force => true do |t|
    t.integer  "user_id"
    t.integer  "project_id"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "associate_maintainers", ["project_id"], :name => "index_associate_maintainers_on_project_id"
  add_index "associate_maintainers", ["user_id"], :name => "index_associate_maintainers_on_user_id"

  create_table "associate_projects_projects", :force => true do |t|
    t.integer "project_id",           :null => false
    t.integer "associate_project_id", :null => false
  end

  add_index "associate_projects_projects", ["associate_project_id"], :name => "index_associate_projects_projects_on_associate_project_id"
  add_index "associate_projects_projects", ["project_id"], :name => "index_associate_projects_projects_on_project_id"

  create_table "blocks", :force => true do |t|
    t.string   "hid"
    t.integer  "doc_id"
    t.integer  "begin"
    t.integer  "end"
    t.string   "category"
    t.integer  "project_id"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "blocks", ["doc_id"], :name => "index_blocks_on_doc_id"
  add_index "blocks", ["project_id"], :name => "index_blocks_on_project_id"

  create_table "delayed_jobs", :force => true do |t|
    t.integer  "priority",   :default => 0, :null => false
    t.integer  "attempts",   :default => 0, :null => false
    t.text     "handler",                   :null => false
    t.text     "last_error"
    t.datetime "run_at"
    t.datetime "locked_at"
    t.datetime "failed_at"
    t.string   "locked_by"
    t.string   "queue"
    t.datetime "created_at",                :null => false
    t.datetime "updated_at",                :null => false
  end

  add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"

  create_table "denotations", :force => true do |t|
    t.string   "hid"
    t.integer  "doc_id"
    t.integer  "begin"
    t.integer  "end"
    t.string   "obj"
    t.integer  "project_id"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "denotations", ["doc_id"], :name => "index_spans_on_doc_id"
  add_index "denotations", ["project_id"], :name => "index_spans_on_project_id"

  create_table "docs", :force => true do |t|
    t.text     "body"
    t.string   "source"
    t.string   "sourcedb"
    t.string   "sourceid"
    t.integer  "serial"
    t.string   "section"
    t.datetime "created_at",                       :null => false
    t.datetime "updated_at",                       :null => false
    t.integer  "denotations_count", :default => 0
    t.integer  "subcatrels_count",  :default => 0
  end

  add_index "docs", ["serial"], :name => "index_docs_on_serial"
  add_index "docs", ["sourcedb"], :name => "index_docs_on_sourcedb"
  add_index "docs", ["sourceid"], :name => "index_docs_on_sourceid"

  create_table "docs_projects", :id => false, :force => true do |t|
    t.integer "project_id"
    t.integer "doc_id"
  end

  add_index "docs_projects", ["project_id", "doc_id"], :name => "index_docs_projects_on_project_id_and_doc_id", :unique => true

  create_table "documentation_categories", :force => true do |t|
    t.string "name", :null => false
  end

  create_table "documentations", :force => true do |t|
    t.string  "title",                     :null => false
    t.string  "body",                      :null => false
    t.integer "documentation_category_id"
  end

  add_index "documentations", ["documentation_category_id"], :name => "index_documentations_on_documentation_category_id"

  create_table "instances", :force => true do |t|
    t.string   "hid"
    t.integer  "obj_id"
    t.string   "pred"
    t.integer  "project_id"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "instances", ["obj_id"], :name => "index_instances_on_obj_id"
  add_index "instances", ["project_id"], :name => "index_instances_on_project_id"

  create_table "modifications", :force => true do |t|
    t.string   "hid"
    t.integer  "obj_id"
    t.string   "obj_type"
    t.string   "pred"
    t.integer  "project_id"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "modifications", ["obj_id"], :name => "index_modifications_on_obj_id"
  add_index "modifications", ["project_id"], :name => "index_modifications_on_project_id"

  create_table "projects", :force => true do |t|
    t.string   "name"
    t.text     "description"
    t.string   "author"
    t.datetime "created_at",                                      :null => false
    t.datetime "updated_at",                                      :null => false
    t.string   "license"
    t.string   "reference"
    t.string   "editor"
    t.integer  "accessibility"
    t.integer  "status"
    t.integer  "user_id"
    t.string   "viewer"
    t.string   "rdfwriter"
    t.string   "xmlwriter"
    t.string   "bionlpwriter"
    t.string   "type"
    t.integer  "pmdocs_count",                     :default => 0
    t.integer  "pmcdocs_count",                    :default => 0
    t.integer  "denotations_count",                :default => 0
    t.integer  "relations_count",                  :default => 0
    t.integer  "pending_associate_projects_count", :default => 0
  end

  add_index "projects", ["name"], :name => "index_annsets_on_name", :unique => true
  add_index "projects", ["name"], :name => "index_projects_on_name", :unique => true

  create_table "relations", :force => true do |t|
    t.string   "hid"
    t.integer  "subj_id"
    t.string   "subj_type"
    t.integer  "obj_id"
    t.string   "obj_type"
    t.string   "pred"
    t.integer  "project_id"
    t.datetime "created_at", :null => false
    t.datetime "updated_at", :null => false
  end

  add_index "relations", ["obj_id"], :name => "index_relations_on_obj_id"
  add_index "relations", ["project_id"], :name => "index_relations_on_project_id"
  add_index "relations", ["subj_id"], :name => "index_relations_on_subj_id"

  create_table "users", :force => true do |t|
    t.string   "email",                  :default => "", :null => false
    t.string   "encrypted_password",     :default => "", :null => false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          :default => 0
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at",                             :null => false
    t.datetime "updated_at",                             :null => false
    t.string   "username"
  end

  add_index "users", ["email"], :name => "index_users_on_email", :unique => true
  add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true

end