public static function run($r)
 {
     echo PHP_EOL . 'If you have not already registered for your free OpenBenchmarking.org account, you can do so at http://openbenchmarking.org/' . PHP_EOL . PHP_EOL . 'Once you have registered your account and clicked the link within the verification email, enter your log-in information below.' . PHP_EOL . PHP_EOL;
     echo 'User-Name: ';
     $username = pts_user_io::read_user_input();
     echo 'Password: '******'s_u' => $username, 's_p' => sha1($password), 's_s' => base64_encode(phodevi::system_software(true)), 's_h' => base64_encode(phodevi::system_hardware(true)));
     $login_state = pts_openbenchmarking::make_openbenchmarking_request('account_login', $login_payload);
     $json = json_decode($login_state, true);
     if (isset($json['openbenchmarking']['response']['error'])) {
         trigger_error($json['openbenchmarking']['response']['error'], E_USER_ERROR);
         pts_storage_object::remove_in_file(PTS_CORE_STORAGE, 'openbenchmarking');
     } else {
         $openbenchmarking_payload = array('user_name' => $json['openbenchmarking']['account']['user_name'], 'communication_id' => $json['openbenchmarking']['account']['communication_id'], 'sav' => $json['openbenchmarking']['account']['sav']);
         pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking', $openbenchmarking_payload);
         echo PHP_EOL . PHP_EOL . 'The Account Has Been Setup.' . PHP_EOL . PHP_EOL;
     }
 }
 public static function process_shutdown_tasks()
 {
     // TODO: possibly do something like posix_getpid() != pts_client::$startup_pid in case shutdown function is called from a child process
     // Generate Phodevi Smart Cache
     if (pts_client::read_env('NO_PHODEVI_CACHE') == false && pts_client::read_env('EXTERNAL_PHODEVI_CACHE') == false) {
         if (pts_config::read_bool_config('PhoronixTestSuite/Options/General/UsePhodeviCache', 'TRUE')) {
             pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'phodevi_smart_cache', phodevi::get_phodevi_cache_object(PTS_USER_PATH, PTS_CORE_VERSION));
         } else {
             pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'phodevi_smart_cache', null);
         }
     }
     if (is_array(self::$lock_pointers)) {
         foreach (array_keys(self::$lock_pointers) as $lock_file) {
             self::release_lock($lock_file);
         }
     }
     foreach (self::$forked_pids as $pid) {
         if (is_dir('/proc/' . $pid) && function_exists('posix_kill')) {
             posix_kill($pid, SIGKILL);
         }
     }
 }
 public static function init_account($openbenchmarking, $settings)
 {
     if (isset($openbenchmarking['user_name']) && isset($openbenchmarking['communication_id']) && isset($openbenchmarking['sav'])) {
         if (IS_FIRST_RUN_TODAY && pts_network::internet_support_available()) {
             // Might as well make sure OpenBenchmarking.org account has the latest system info
             // But don't do it everytime to preserve bandwidth
             $openbenchmarking['s_s'] = base64_encode(phodevi::system_software(true));
             $openbenchmarking['s_h'] = base64_encode(phodevi::system_hardware(true));
             $return_state = pts_openbenchmarking::make_openbenchmarking_request('account_verify', $openbenchmarking);
             $json = json_decode($return_state, true);
             if (isset($json['openbenchmarking']['account']['valid'])) {
                 // The account is valid
                 self::$openbenchmarking_account = $openbenchmarking;
                 self::$client_settings = $json['openbenchmarking']['account']['settings'];
                 pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking_account_settings', $json['openbenchmarking']['account']['settings']);
             } else {
                 pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'openbenchmarking', false);
                 trigger_error('Invalid OpenBenchmarking.org account supplied, please re-login.', E_USER_ERROR);
             }
         } else {
             self::$openbenchmarking_account = $openbenchmarking;
             self::$client_settings = $settings;
         }
     }
 }
 public static function save_setting($setting, $value)
 {
     return pts_storage_object::set_in_file(self::$json_storage, $setting, $value);
 }
 private static function save_download_speed_averages()
 {
     pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'download_average_count', self::$average_count);
     pts_storage_object::set_in_file(PTS_CORE_STORAGE, 'download_average_speed', self::$average_speed);
 }