Exemplo n.º 1
0
 public String getOs() {
   if (System.getProperty("os.name").toLowerCase().contains("nux")) {
     if (isArm()) {
       return "-arm";
     }
     if (is64()) {
       return "-nix64";
     } else {
       return "-nix32";
     }
   }
   if (System.getProperty("os.name").toLowerCase().contains("mac")) {
     return "-osx";
   }
   return null;
 }
Exemplo n.º 2
0
  @Override
  @Port(name = "files", method = "getFileContent")
  public byte[] getFileContent(String relativePath /*, Boolean lock*/) {

    long newtime = System.currentTimeMillis();

    if (newtime - lastRevisionCheck > delay) {
      pull();
      lastRevisionCheck = newtime;
    }

    return super.getFileContent(relativePath);
  }
Exemplo n.º 3
0
  @Start
  public void start() {
    try {
      // todo check if not used
      ipc_key = gerRandom();
      ArrayList<String> repos = new ArrayList<String>();
      for (Repository repo : getModelService().getLastModel().getRepositoriesForJ()) {
        repos.add(repo.getUrl());
      }
      // loading model from jar
      ContainerRoot model =
          KevoreeXmiHelper.loadStream(getClass().getResourceAsStream("/KEV-INF/lib.kev"));
      File binary =
          getBootStrapperService()
              .resolveArtifact(
                  "org.kevoree.library.nativeN.faceDetection-wrapper" + getOs(),
                  "org.kevoree.library.nativeN",
                  "1.8.9-SNAPSHOT",
                  "uexe",
                  repos);
      if (binary != null) {
        if (!binary.canExecute()) {
          binary.setExecutable(true);
        }

        JarFile jarFile =
            new JarFile(
                getBootStrapperService()
                    .resolveArtifact(
                        "org.kevoree.library.nativeN.faceDetection-wrapper",
                        "org.kevoree.library.nativeN",
                        "1.8.9-SNAPSHOT",
                        "jar",
                        repos));

        final Enumeration<JarEntry> entries = jarFile.entries();
        while (entries.hasMoreElements()) {
          final JarEntry entry = entries.nextElement();
          if (entry.getName().contains(".")
              && !entry.getName().endsWith(".class")
              && !entry.getName().contains("META-INF")) {
            System.out.println("File : " + entry.getName());
            JarEntry fileEntry = jarFile.getJarEntry(entry.getName());
            InputStream input = jarFile.getInputStream(fileEntry);

            String file = System.getProperty("java.io.tmpdir") + entry.getName();
            File d = new File(file);
            d.mkdirs();
            FileManager.copyFileFromStream(
                input,
                System.getProperty("java.io.tmpdir") + "/FaceDetection/",
                entry.getName(),
                true);
          }
        }

        nativeManager = new NativeManager(ipc_key, binary.getPath(), model);

        nativeManager.addEventListener(
            new NativeListenerPorts() {
              @Override
              public void disptach(NativeEventPort event, String port_name, String msg) {
                MessagePort port = (MessagePort) getPortByName(port_name);
                port.process(msg);
              }
            });

        started = nativeManager.start();

        nativeManager.setDico("video", getDictionary().get("video").toString());

      } else {
        System.err.println(
            "The binary org.kevoree.library.nativeN.faceDetection-wrapper for the architecture "
                + getOs()
                + " is not found");
      }

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 4
0
 public boolean is64() {
   String os = System.getProperty("os.arch").toLowerCase();
   return (os.contains("64"));
 }