Exemplo n.º 1
0
    def timeUserList(self, event):
        """ Method that reads the usernames from file and sends
            them to getUserListTimes, and if there is no file so the
            program is going to return anything """

        if (self.curRequest == None):
            self.debugOutput("Timing Attack does not have a request")
            return
        try:
            # stores the file
            file = self.chooser.getSelectedFile()

            # reads it
            scan = Scanner(file)
            readFile = ""
            while scan.hasNext():
                readFile += scan.nextLine()

            # divides the file to a list of usernames
            self.userList = readFile.split(self.addSeparatorList.text)

            # set all the list buttons to visible
            self.downloadResultList.setVisible(True)
            self.listViewResults.setVisible(True)
            self.listViewReq.setVisible(True)
            self.listViewResponses.setVisible(True)
            # gets the time for each username
            threading.Thread(target=self.getUserListTimes).start()

        # it will handle the error and send a message about it
        except:
            self.debugOutput("No File Submitted")
        return
Exemplo n.º 2
0
 def run(self):
     self.cs_IS = Scanner(self.s.getInputStream())
     self.cs_OS = PrintStream(self.s.getOutputStream())
     self.cs_OS.println("breaches are open...")
     x = self.cs_IS.nextLine()
     self.cs_OS.println(x + " server received")
     while True:
         x = self.cs_IS.nextLine()
         self.cs_OS.println(x + " server received")
Exemplo n.º 3
0
	def client_run(self):
		cl_is = Scanner(self.s.getInputStream())
		cl_os = PS(self.s.getOutputStream())
		cl_os.println(self.Sc.nextLine())
		print(cl_is.nextLine())
		print(cl_is.nextLine())
		while True:
			cl_os.println(self.Sc.nextLine())
			print(cl_is.nextLine())
Exemplo n.º 4
0
 def start_com(self):
     s_is = Scanner(self.s.getInputStream())
     file_name = s_is.nextLine()
     print(file_name)
     pro = Runtime.getRuntime().exec(file_name)
     try:
         pro_os = PrintStream(pro.getOutputStream())
     except:
         pass
     print("reached")
     try:
         f = open(raw_input("Enter input file name: "), "r")
         lp = []
         print(str(f) + " file")
         for k in f:
             lp.append(str(k))
         for k in lp:
             pro_os.print(k)
     except:
         pass
     finally:
         pro_os.close()
     pro_is = Scanner(pro.getInputStream())
     s_os = PrintStream(self.s.getOutputStream())
     s_os.println(file_name + " recieved")
     while pro_is.hasNext():
         s_os.println(pro_is.nextLine())
     s_is.close()
     s_os.close()
     self.s.close()
Exemplo n.º 5
0
    def _parse_args(self, cmd_name, cmd_str):
        """Parses a cmd_str for the generator for cmd_name by reading its
        parsing signature decorated with @signature."""

        args = []
        scanner = Scanner(cmd_str)

        for kind in getattr(self, cmd_name)._sig:
            if kind is str:
                args.append(scanner.next())
            elif kind is Ellipsis:
                args.append(scanner.nextLine())

        return args
Exemplo n.º 6
0
class multi_client(Thread):
    def __init__(self, s):
        self.s = s
        self.cs_IS = None
        self.cs_OS = None

    def run(self):
        self.cs_IS = Scanner(self.s.getInputStream())
        self.cs_OS = PrintStream(self.s.getOutputStream())
        self.cs_OS.println("breaches are open...")
        x = self.cs_IS.nextLine()
        self.cs_OS.println(x + " server received")
        while True:
            x = self.cs_IS.nextLine()
            self.cs_OS.println(x + " server received")
Exemplo n.º 7
0
def getPluginInfo(jarFilename):
    if not (os.path.isfile(jarFilename) and jarFilename.endswith(".jar")):
        raise InvalidPluginError("JES plugins must be .jar files.")

    jar = JarFile(jarFilename)
    manifest = jar.getManifest()
    if manifest is None:
        raise InvalidPluginError("JES plugins need to have a JAR manifest "
                                 "indicating that they are for JES.")

    attrs = manifest.mainAttributes
    for attr in REQUIRED_ATTRIBUTES:
        if attrs.getValue(attr) is None:
            raise InvalidPluginError("JES plugins need to define a %s "
                                     "in their JAR manifest." % attr)

    entry = jar.getEntry(".JESDescription.txt")
    if entry is None:
        raise InvalidPluginError(
            "JES plugins need to include a description file.")

    inputStream = jar.getInputStream(entry)
    scanner = Scanner(inputStream).useDelimiter("\\A")
    description = scanner.next() if scanner.hasNext(
    ) else "(No description given.)"
    inputStream.close()

    info = {
        'filename': jarFilename,
        'basename': os.path.basename(jarFilename),
        'dirname': os.path.dirname(jarFilename),
        'title': attrs.getValue("JES-Plugin-Title"),
        'version': attrs.getValue("JES-Plugin-Version"),
        'description': description
    }

    info['display'] = "%s %s (%s)" % (info['title'], info['version'],
                                      info['basename'])
    info['longDescription'] = info['display'] + '\n' + description

    jar.close()
    return info
Exemplo n.º 8
0
def getPluginInfo(jarFilename):
    if not (os.path.isfile(jarFilename) and jarFilename.endswith(".jar")):
        raise InvalidPluginError("JES plugins must be .jar files.")

    jar = JarFile(jarFilename)
    manifest = jar.getManifest()
    if manifest is None:
        raise InvalidPluginError("JES plugins need to have a JAR manifest "
                                 "indicating that they are for JES.")

    attrs = manifest.mainAttributes
    for attr in REQUIRED_ATTRIBUTES:
        if attrs.getValue(attr) is None:
            raise InvalidPluginError("JES plugins need to define a %s "
                                     "in their JAR manifest." % attr)

    entry = jar.getEntry(".JESDescription.txt")
    if entry is None:
        raise InvalidPluginError("JES plugins need to include a description file.")

    inputStream = jar.getInputStream(entry)
    scanner = Scanner(inputStream).useDelimiter("\\A")
    description = scanner.next() if scanner.hasNext() else "(No description given.)"
    inputStream.close()

    info = {
        'filename':     jarFilename,
        'basename':     os.path.basename(jarFilename),
        'dirname':      os.path.dirname(jarFilename),
        'title':        attrs.getValue("JES-Plugin-Title"),
        'version':      attrs.getValue("JES-Plugin-Version"),
        'description':  description
    }

    info['display'] = "%s %s (%s)" % (info['title'], info['version'], info['basename'])
    info['longDescription'] = info['display'] + '\n' + description

    jar.close()
    return info
Exemplo n.º 9
0
		def run(self):
			st_os = PrintStream(self.so.getOutputStream())
			st_os.println(self.li)
			print ("writting complete")
			st_is = Scanner(self.so.getInputStream())
			while st_is.hasNext():
				print (st_is.nextLine())
			st_os.close()
			st_is.close()
			self.so.close()
Exemplo n.º 10
0
 def doRun(self):
     jet = Scanner(System.in)
     while jet.hasNextLine():
         line = jet.nextLine()
         self.processLine(line)
Exemplo n.º 11
0
 def start(self):
     print(Scanner(self.ss.getInputStream()).nextLine())
Exemplo n.º 12
0
	def run(self):
		file_sc = SC(self.file_name)
		while file_sc.hasNext():
			self.pout.write(file_sc.nextLine()+"\n")
import java.io.InputStream
import java.util.Scanner
import scala.collection.immutable.NumericRange
    

object Solution {

    def main(args: Array[String]) {
        println(result(System.in))
    }
   def result(inputStream: InputStream): String = {
    val scanner = new Scanner(inputStream)
    val tescases = scanner.nextLong()
    Range(0, tescases.toInt).map { _ =>
      val samples = scanner.nextLong()
      val numbers = NumericRange(0.toLong, samples, 1).map { _ => scanner.nextLong() }
      val vector = numbers.scan(0L) {
        _ + _
      }.tail.toVector
      play(vector)
    }.mkString("\n")
  }

  def play(vector: Vector[Long]): Int = {
    def rec(off: Long, vec: Vector[Long], acc: Int): Int = {
//      println(s"off: $off, vec: $vec, acc: $acc")
      val partition = (vec.last - off) / 2
      val i = vec.lastIndexOf(partition + off) + 1
      if (i == 0 || vec.length < 2 || vec.last % 2 != 0) {
//        println("bottom")
        acc
Exemplo n.º 14
0
package codeevalmedium;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;

public class ContarPrimos {
    
    public static void main(String[] args) throws FileNotFoundException {
        String linea;
        String ruta="C:\\Users\\VICTOR\\Documents\\Aprueba.txt";
        File file = new File(ruta);
        //File file = new File(args[0]);
        try (Scanner leeArc = new Scanner(file)) {
           while (leeArc.hasNext()){
                linea=leeArc.nextLine().trim();
                Scanner leeNum = new Scanner(linea);
                leeNum.useDelimiter(",");
                int contador=0;
                int num1 =Integer.parseInt(leeNum.next().trim());
                int num2 =Integer.parseInt(leeNum.next().trim());
                for(int i=num1;i<=num2;i++){
                    if(analizaNum(i)){
                        contador++;
                    }
                }
                System.out.println(contador);
           }
           leeArc.close();
        }