<commit_before>extern crate wm_daemons;
use wm_daemons::config::{load_config, load_config_path};
use wm_daemons::dbus_listen::{CallbackMap, DBusInfo, match_signal};
use wm_daemons::exec::{CommandLine, read_command_line_from_config, run_command_line};

#[macro_use]
extern crate clap;
use clap::{Arg, App};

extern crate dbus;
use self::dbus::{Connection, BusType, Message};

use std::env::var;
use std::error::Error;
use std::path::Path;

struct Context {
    on_lock: Option<CommandLine>,
    on_unlock: Option<CommandLine>,
}

fn run_program(action: &str, cmd_line: &Option<CommandLine>) -> () {
    cmd_line.as_ref().map(|ref cmd| {
        let res = run_command_line(&cmd);
        res.unwrap_or_else(|err| {
            println!("failed to handle '{}' action: {}", action, err);
        });
    });
}

fn handle_signal(ctx: Context, info: &Message) -> Context {
    let (_, _, _, member) = info.headers();

    member.map(|member_name| {
        if member_name == "Lock" {
            run_program("lock", &ctx.on_lock);
        } else if member_name == "Unlock" {
            run_program("unlock", &ctx.on_unlock);
        }
    });

    ctx
}

fn try_main() -> Result<(), Box<Error>> {
    let matches = App::new("wm-session-agent")
        .version(&crate_version!()[..])<commit_msg>wm-session-agent: remove last 'unwrap' usage<commit_after>extern crate wm_daemons;
use wm_daemons::config::{load_config, load_config_path};
use wm_daemons::dbus_listen::{CallbackMap, DBusInfo, match_signal};
use wm_daemons::exec::{CommandLine, read_command_line_from_config, run_command_line};

#[macro_use]
extern crate clap;
use clap::{Arg, App};

extern crate dbus;
use self::dbus::{Connection, BusType, Message};

use std::env::var;
use std::error::Error;
use std::path::Path;

struct Context {
    on_lock: Option<CommandLine>,
    on_unlock: Option<CommandLine>,
}

fn run_program(action: &str, cmd_line: &Option<CommandLine>) -> () {
    cmd_line.as_ref().map(|ref cmd| {
        let _ = run_command_line(&cmd).map_err(|err| {
                println!("failed to handle '{}' action: {}", action, err);
            });
    });
}

fn handle_signal(ctx: Context, info: &Message) -> Context {
    let (_, _, _, member) = info.headers();

    member.map(|member_name| {
        if member_name == "Lock" {
            run_program("lock", &ctx.on_lock);
        } else if member_name == "Unlock" {
            run_program("unlock", &ctx.on_unlock);
        }
    });

    ctx
}

fn try_main() -> Result<(), Box<Error>> {
    let matches = App::new("wm-session-agent")
        .version(&crate_version!()[..])
{'fraction_non_alphanumeric': 0.1686561417019638, 'fraction_numerical': 0.0, 'mean_word_length': 3.775735294117647, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '787121', 'n_tokens_mistral': 889, 'n_tokens_neox': 893, 'n_words': 175}