<commit_before>package magnum.antimalware

import scala.sys.process._
import scala.language.reflectiveCalls

import org.rogach.scallop.ScallopConf;

import java.io.File

import clasp._
import clasp.core.sdktools.EmulatorOptions

object Main extends App {
  val emuOpts = new EmulatorOptions
  emuOpts.noBootAnim = true; //emuOpts.noWindow = true;
  emuOpts.noSnapShotLoad = true; emuOpts.noAudio = true;
  emuOpts.noSkin = true; emuOpts.wipeData = true;
  emuOpts.httpProxy = "0.0.0.0:0"; emuOpts.gpuMode = "off";
  // TODO: Still getting warning: 'Failed to Initialize backend EGL display'
  // TODO: Is wipeData working?

  val opts = new AntimalwareConf(args)

  if(opts.client()) {
    new ClaspClient(opts, emuOpts)
  } else {
    // TODO: Make sure this is working.
    val profilerApk = new File((opts.profilerApk.get orElse
      Option[String]("../profiler/bin/Profiler-debug.apk")).get)
    
    if (!profilerApk.exists) {
      println("s'$profiler' not found. Exiting.")
      System.exit(42)
    }

    if (!opts.appsTag.isSupplied || !opts.arffTag.isSupplied) {
      println("Error: `appsTag` and `arffTag` are both required.")
      System.exit(42)
    }
    Driver.run(new ClaspMaster(opts), profilerApk.getPath,
      opts.appsTag.apply, opts.arffTag.apply)
  }
}

class AntimalwareConf(args: Seq[String]) extends ClaspConf(args) {
  version("Antimalware driver.")
  banner("""Antimalware's driver dynamically profiles a set of applications
           |to obtain a set of feature vectors.
           |
           | + The application set is `../apps/<appsTag>`.
           | + The feature vector set is `../arff/<arffTag>`.
           |
           |Where <appsTag> and <arffTag> are arguments described below.
           |
           |Argument list.
  """.stripMargin)
  val profilerApk = opt[String] (
    "profilerApk", descr="Path to the profiler APK.")
  val appsTag = opt[String] (
    "appsTag", descr="Specific tag within the `apps` directory to pull from.")
     //required=true)
   // TODO: We can't require any options because the clients
   // use this class for configuration.
  val arffTag = opt[String] (
    "arffTag", descr="Specific tag within the `arff` directory to pull from.")
  val help = opt[Boolean]("help",
    noshort = true, descr = "Show this message.")
}<commit_msg>Antimalware: Wording.<commit_after>package magnum.antimalware

import scala.sys.process._
import scala.language.reflectiveCalls

import org.rogach.scallop.ScallopConf;

import java.io.File

import clasp._
import clasp.core.sdktools.EmulatorOptions

object Main extends App {
  val emuOpts = new EmulatorOptions
  emuOpts.noBootAnim = true; //emuOpts.noWindow = true;
  emuOpts.noSnapShotLoad = true; emuOpts.noAudio = true;
  emuOpts.noSkin = true; emuOpts.wipeData = true;
  emuOpts.httpProxy = "0.0.0.0:0"; emuOpts.gpuMode = "off";
  // TODO: Still getting warning: 'Failed to Initialize backend EGL display'
  // TODO: Is wipeData working?

  val opts = new AntimalwareConf(args)

  if(opts.client()) {
    new ClaspClient(opts, emuOpts)
  } else {
    // TODO: Make sure this is working.
    val profilerApk = new File((opts.profilerApk.get orElse
      Option[String]("../profiler/bin/Profiler-debug.apk")).get)
    
    if (!profilerApk.exists) {
      println("s'$profiler' not found. Exiting.")
      System.exit(42)
    }

    if (!opts.appsTag.isSupplied || !opts.arffTag.isSupplied) {
      println("Error: `appsTag` and `arffTag` are both required.")
      System.exit(42)
    }
    Driver.run(new ClaspMaster(opts), profilerApk.getPath,
      opts.appsTag.apply, opts.arffTag.apply)
  }
}

class AntimalwareConf(args: Seq[String]) extends ClaspConf(args) {
  version("Antimalware driver.")
  banner("""Antimalware's driver dynamically profiles a set of applications
           |to obtain a set of feature vectors.
           |
           | + The application set is `../apps/<appsTag>`.
           | + The feature vector set is `../arff/<arffTag>`.
           |
           |Where <appsTag> and <arffTag> are arguments described below.
           |
           |Argument list.
  """.stripMargin)
  val profilerApk = opt[String] (
    "profilerApk", descr="Path to the profiler APK.")
  val appsTag = opt[String] (
    "appsTag", descr="Specific tag within the `apps` directory to use.")
     //required=true)
   // TODO: We can't require any options because the clients
   // use this class for configuration.
  val arffTag = opt[String] (
    "arffTag", descr="Specific tag within the `arff` directory to use.")
  val help = opt[Boolean]("help",
    noshort = true, descr = "Show this message.")
}
{'fraction_non_alphanumeric': 0.12424242424242424, 'fraction_numerical': 0.003896103896103896, 'mean_word_length': 3.093002657218778, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4443184', 'n_tokens_mistral': 1542, 'n_tokens_neox': 1532, 'n_words': 397}