Commit 78a1f98e 78a1f98ebec072e54ffc43194227ca4506f518c9 by root

save

1 parent 0dbe71f2
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DisplayCalibrator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
org.eclipse.jdt.core.compiler.compliance=1.5
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.5
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>HardwareConfig</groupId>
<artifactId>DisplayCalibration</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DisplayCalibration</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package org.emercit.displaycalibrator;
/**
* Hello world!
*
*/
import org.emercit.displaycalibrator.service.DCalibratorBB;
public class App
{
public static void main( String[] args )
{
DCalibratorBB dcbb=new DCalibratorBB();
dcbb.Run("/home/debian/start-xinput-config.sh");
}
}
package org.emercit.displaycalibrator.service;
public interface DCalibrator {
public void Run(String cmd);
}
package org.emercit.displaycalibrator.service;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.util.Vector;
public class DCalibratorBB implements DCalibrator {
public void Run(String cmd) {
try {
Vector<String> params=ExcecCmd(cmd);
File file = new File("/etc/X11/xorg.conf.d/99-calibration.conf");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write("#Generated by DisplayCalibrator\n");
bw.write("\n");
for (int i=9;i<params.size();i++) {
bw.write(params.get(i));
bw.write("\n");
}
bw.close();
}catch(Exception e) {
}
}
private Vector<String> ExcecCmd(String cmd) throws Exception {
Vector<String> v=new Vector<String>();
Runtime run = Runtime.getRuntime();
Process proc = run.exec(new String[]{"/bin/sh", "-c",cmd});
proc.waitFor();
BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream()));
while(br.ready()) {
v.add(br.readLine());
}
return v;
}
}
package HardwareConfig.DisplayCalibration;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>DtManager</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.source=1.7
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.emercit</groupId>
<artifactId>DtManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>DtManager</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
<showDeprecation>true</showDeprecation>
<showWarnings>true</showWarnings>
<executable>${env.JAVA_HOME_7}/bin/javac</executable>
<fork>true</fork>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.emercit</groupId>
<artifactId>pckutils</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<repositories>
<!--other repositories if any-->
<repository>
<id>project.local</id>
<name>project</name>
<url>file:/opt/devtools/repo</url>
</repository>
</repositories>
</project>
package org.emercit.dtmanager;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
import org.emercit.dtmanager.service.NtpLinux;
public class App
{
public static void main( String[] args )
{
/*
#server 0.it.pool.ntp.org iburst
#server 1.it.pool.ntp.org iburst
#server 2.it.pool.ntp.org iburst
server 3.it.pool.ntp.org iburst
restrict default nomodify nopeer
restrict 0.0.0.0
driftfile /var/lib/ntp/ntp.drift
logfile /var/log/ntp.log
*/
/*
Calendar calendar = Calendar.getInstance();
TimeZone timeZone = calendar.getTimeZone();
String[] tzAll=timeZone.getAvailableIDs();
for (String tz:tzAll) {
System.out.println(tz);
}
*/
Calendar calendar = Calendar.getInstance();
TimeZone.setDefault(TimeZone.getTimeZone("UTC"));
// calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
TimeZone timeZone = calendar.getTimeZone();
Date date=calendar.getTime();
String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
System.out.println(formattedDate);
System.out.println(timeZone.getID());
}
}
package org.emercit.dtmanager.model;
public class DateInfo {
public String dt;
public String ntp;
}
package org.emercit.dtmanager.model;
import java.io.Serializable;
import java.util.Vector;
public class NtpServerBean implements Serializable {
private static final long serialVersionUID = 1L;
private String ntpserver;
public NtpServerBean() {
}
public void setNtpserver(String value) {
this.ntpserver=value;
}
public String getNtpServer() {
return ntpserver;
}
}
package org.emercit.dtmanager.service;
public interface INtp {
public String getUseNtpServer();
public boolean setUsNtpServer(String value);
}
package org.emercit.dtmanager.service;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.emercit.pckutils.cmd.CmdExec;
public class NtpLinux implements INtp {
private CmdExec cmdexec=new CmdExec();
public String getUseNtpServer() {
try {
return cmdexec.Run("cat /etc/ntp.conf | grep server | awk '{print $2}'").firstElement();
}catch(Exception e) {
return null;
}
}
public boolean setUsNtpServer(String value) {
try {
File file = new File("/etc/ntp.conf");
if (!file.exists()) {
file.createNewFile();
}
FileWriter fw = new FileWriter(file.getAbsoluteFile());
BufferedWriter bw = new BufferedWriter(fw);
bw.write("#Generated by DtManager");
bw.write("\n");
bw.write("\n");
bw.write("server");
bw.write(" ");
bw.write(value);
bw.write(" ");
bw.write("iburst");
bw.write("\n");
bw.write("\n");
bw.write("restrict default nomodify nopeer");
bw.write("\n");
bw.write("restrict 0.0.0.0");
bw.write("\n");
bw.write("\n");
bw.write("driftfile /var/lib/ntp/ntp.drift");
bw.write("\n");
bw.write("logfile /var/log/ntp.log");
bw.write("\n");
bw.close();
} catch (IOException e) {
return false;
}
return true;
}
}
package org.emercit.DtManager;
import junit.framework.Test;
import junit.framework.TestCase;
import junit.framework.TestSuite;
/**
* Unit test for simple App.
*/
public class AppTest
extends TestCase
{
/**
* Create the test case
*
* @param testName name of the test case
*/
public AppTest( String testName )
{
super( testName );
}
/**
* @return the suite of tests being tested
*/
public static Test suite()
{
return new TestSuite( AppTest.class );
}
/**
* Rigourous Test :-)
*/
public void testApp()
{
assertTrue( true );
}
}