save
Showing
24 changed files
with
565 additions
and
0 deletions
DisplayCalibrator/.classpath
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <classpath> | ||
| 3 | <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
| 4 | <attributes> | ||
| 5 | <attribute name="optional" value="true"/> | ||
| 6 | <attribute name="maven.pomderived" value="true"/> | ||
| 7 | </attributes> | ||
| 8 | </classpathentry> | ||
| 9 | <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| 10 | <attributes> | ||
| 11 | <attribute name="optional" value="true"/> | ||
| 12 | <attribute name="maven.pomderived" value="true"/> | ||
| 13 | </attributes> | ||
| 14 | </classpathentry> | ||
| 15 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"> | ||
| 16 | <attributes> | ||
| 17 | <attribute name="maven.pomderived" value="true"/> | ||
| 18 | </attributes> | ||
| 19 | </classpathentry> | ||
| 20 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
| 21 | <attributes> | ||
| 22 | <attribute name="maven.pomderived" value="true"/> | ||
| 23 | </attributes> | ||
| 24 | </classpathentry> | ||
| 25 | <classpathentry kind="output" path="target/classes"/> | ||
| 26 | </classpath> |
DisplayCalibrator/.gitignore
0 → 100644
| 1 | /target |
DisplayCalibrator/.project
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <projectDescription> | ||
| 3 | <name>DisplayCalibrator</name> | ||
| 4 | <comment></comment> | ||
| 5 | <projects> | ||
| 6 | </projects> | ||
| 7 | <buildSpec> | ||
| 8 | <buildCommand> | ||
| 9 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
| 10 | <arguments> | ||
| 11 | </arguments> | ||
| 12 | </buildCommand> | ||
| 13 | <buildCommand> | ||
| 14 | <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| 15 | <arguments> | ||
| 16 | </arguments> | ||
| 17 | </buildCommand> | ||
| 18 | </buildSpec> | ||
| 19 | <natures> | ||
| 20 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
| 21 | <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| 22 | </natures> | ||
| 23 | </projectDescription> |
DisplayCalibrator/pom.xml
0 → 100644
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 2 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 3 | <modelVersion>4.0.0</modelVersion> | ||
| 4 | |||
| 5 | <groupId>HardwareConfig</groupId> | ||
| 6 | <artifactId>DisplayCalibration</artifactId> | ||
| 7 | <version>0.0.1-SNAPSHOT</version> | ||
| 8 | <packaging>jar</packaging> | ||
| 9 | |||
| 10 | <name>DisplayCalibration</name> | ||
| 11 | <url>http://maven.apache.org</url> | ||
| 12 | |||
| 13 | <properties> | ||
| 14 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 15 | </properties> | ||
| 16 | |||
| 17 | <dependencies> | ||
| 18 | <dependency> | ||
| 19 | <groupId>junit</groupId> | ||
| 20 | <artifactId>junit</artifactId> | ||
| 21 | <version>3.8.1</version> | ||
| 22 | <scope>test</scope> | ||
| 23 | </dependency> | ||
| 24 | </dependencies> | ||
| 25 | </project> |
| 1 | package org.emercit.displaycalibrator; | ||
| 2 | |||
| 3 | /** | ||
| 4 | * Hello world! | ||
| 5 | * | ||
| 6 | */ | ||
| 7 | |||
| 8 | import org.emercit.displaycalibrator.service.DCalibratorBB; | ||
| 9 | |||
| 10 | |||
| 11 | public class App | ||
| 12 | { | ||
| 13 | public static void main( String[] args ) | ||
| 14 | { | ||
| 15 | |||
| 16 | DCalibratorBB dcbb=new DCalibratorBB(); | ||
| 17 | |||
| 18 | dcbb.Run("/home/debian/start-xinput-config.sh"); | ||
| 19 | |||
| 20 | } | ||
| 21 | } |
| 1 | package org.emercit.displaycalibrator.service; | ||
| 2 | |||
| 3 | import java.io.BufferedReader; | ||
| 4 | import java.io.BufferedWriter; | ||
| 5 | import java.io.File; | ||
| 6 | import java.io.FileWriter; | ||
| 7 | import java.io.InputStreamReader; | ||
| 8 | import java.util.Vector; | ||
| 9 | |||
| 10 | |||
| 11 | public class DCalibratorBB implements DCalibrator { | ||
| 12 | |||
| 13 | |||
| 14 | |||
| 15 | |||
| 16 | |||
| 17 | public void Run(String cmd) { | ||
| 18 | try { | ||
| 19 | Vector<String> params=ExcecCmd(cmd); | ||
| 20 | |||
| 21 | |||
| 22 | |||
| 23 | File file = new File("/etc/X11/xorg.conf.d/99-calibration.conf"); | ||
| 24 | |||
| 25 | if (!file.exists()) { | ||
| 26 | file.createNewFile(); | ||
| 27 | } | ||
| 28 | |||
| 29 | FileWriter fw = new FileWriter(file.getAbsoluteFile()); | ||
| 30 | BufferedWriter bw = new BufferedWriter(fw); | ||
| 31 | |||
| 32 | bw.write("#Generated by DisplayCalibrator\n"); | ||
| 33 | bw.write("\n"); | ||
| 34 | |||
| 35 | for (int i=9;i<params.size();i++) { | ||
| 36 | |||
| 37 | bw.write(params.get(i)); | ||
| 38 | bw.write("\n"); | ||
| 39 | } | ||
| 40 | |||
| 41 | bw.close(); | ||
| 42 | }catch(Exception e) { | ||
| 43 | |||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | |||
| 48 | |||
| 49 | |||
| 50 | |||
| 51 | private Vector<String> ExcecCmd(String cmd) throws Exception { | ||
| 52 | |||
| 53 | Vector<String> v=new Vector<String>(); | ||
| 54 | |||
| 55 | Runtime run = Runtime.getRuntime(); | ||
| 56 | |||
| 57 | Process proc = run.exec(new String[]{"/bin/sh", "-c",cmd}); | ||
| 58 | proc.waitFor(); | ||
| 59 | BufferedReader br = new BufferedReader(new InputStreamReader(proc.getInputStream())); | ||
| 60 | while(br.ready()) { | ||
| 61 | v.add(br.readLine()); | ||
| 62 | } | ||
| 63 | |||
| 64 | return v; | ||
| 65 | } | ||
| 66 | |||
| 67 | } |
| 1 | package HardwareConfig.DisplayCalibration; | ||
| 2 | |||
| 3 | import junit.framework.Test; | ||
| 4 | import junit.framework.TestCase; | ||
| 5 | import junit.framework.TestSuite; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * Unit test for simple App. | ||
| 9 | */ | ||
| 10 | public class AppTest | ||
| 11 | extends TestCase | ||
| 12 | { | ||
| 13 | /** | ||
| 14 | * Create the test case | ||
| 15 | * | ||
| 16 | * @param testName name of the test case | ||
| 17 | */ | ||
| 18 | public AppTest( String testName ) | ||
| 19 | { | ||
| 20 | super( testName ); | ||
| 21 | } | ||
| 22 | |||
| 23 | /** | ||
| 24 | * @return the suite of tests being tested | ||
| 25 | */ | ||
| 26 | public static Test suite() | ||
| 27 | { | ||
| 28 | return new TestSuite( AppTest.class ); | ||
| 29 | } | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Rigourous Test :-) | ||
| 33 | */ | ||
| 34 | public void testApp() | ||
| 35 | { | ||
| 36 | assertTrue( true ); | ||
| 37 | } | ||
| 38 | } |
DtManager/.classpath
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <classpath> | ||
| 3 | <classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
| 4 | <attributes> | ||
| 5 | <attribute name="optional" value="true"/> | ||
| 6 | <attribute name="maven.pomderived" value="true"/> | ||
| 7 | </attributes> | ||
| 8 | </classpathentry> | ||
| 9 | <classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
| 10 | <attributes> | ||
| 11 | <attribute name="optional" value="true"/> | ||
| 12 | <attribute name="maven.pomderived" value="true"/> | ||
| 13 | </attributes> | ||
| 14 | </classpathentry> | ||
| 15 | <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
| 16 | <attributes> | ||
| 17 | <attribute name="maven.pomderived" value="true"/> | ||
| 18 | </attributes> | ||
| 19 | </classpathentry> | ||
| 20 | <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"> | ||
| 21 | <attributes> | ||
| 22 | <attribute name="maven.pomderived" value="true"/> | ||
| 23 | </attributes> | ||
| 24 | </classpathentry> | ||
| 25 | <classpathentry kind="output" path="target/classes"/> | ||
| 26 | </classpath> |
DtManager/.gitignore
0 → 100644
| 1 | /target |
DtManager/.project
0 → 100644
| 1 | <?xml version="1.0" encoding="UTF-8"?> | ||
| 2 | <projectDescription> | ||
| 3 | <name>DtManager</name> | ||
| 4 | <comment></comment> | ||
| 5 | <projects> | ||
| 6 | </projects> | ||
| 7 | <buildSpec> | ||
| 8 | <buildCommand> | ||
| 9 | <name>org.eclipse.jdt.core.javabuilder</name> | ||
| 10 | <arguments> | ||
| 11 | </arguments> | ||
| 12 | </buildCommand> | ||
| 13 | <buildCommand> | ||
| 14 | <name>org.eclipse.m2e.core.maven2Builder</name> | ||
| 15 | <arguments> | ||
| 16 | </arguments> | ||
| 17 | </buildCommand> | ||
| 18 | </buildSpec> | ||
| 19 | <natures> | ||
| 20 | <nature>org.eclipse.jdt.core.javanature</nature> | ||
| 21 | <nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
| 22 | </natures> | ||
| 23 | </projectDescription> |
DtManager/pom.xml
0 → 100644
| 1 | <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 2 | xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| 3 | <modelVersion>4.0.0</modelVersion> | ||
| 4 | |||
| 5 | <groupId>org.emercit</groupId> | ||
| 6 | <artifactId>DtManager</artifactId> | ||
| 7 | <version>0.0.1-SNAPSHOT</version> | ||
| 8 | <packaging>jar</packaging> | ||
| 9 | |||
| 10 | <name>DtManager</name> | ||
| 11 | <url>http://maven.apache.org</url> | ||
| 12 | |||
| 13 | <properties> | ||
| 14 | <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
| 15 | </properties> | ||
| 16 | |||
| 17 | <build> | ||
| 18 | <plugins> | ||
| 19 | <plugin> | ||
| 20 | <groupId>org.apache.maven.plugins</groupId> | ||
| 21 | <artifactId>maven-compiler-plugin</artifactId> | ||
| 22 | <configuration> | ||
| 23 | <source>1.7</source> | ||
| 24 | <target>1.7</target> | ||
| 25 | <showDeprecation>true</showDeprecation> | ||
| 26 | <showWarnings>true</showWarnings> | ||
| 27 | <executable>${env.JAVA_HOME_7}/bin/javac</executable> | ||
| 28 | <fork>true</fork> | ||
| 29 | </configuration> | ||
| 30 | </plugin> | ||
| 31 | </plugins> | ||
| 32 | |||
| 33 | </build> | ||
| 34 | |||
| 35 | <dependencies> | ||
| 36 | <dependency> | ||
| 37 | <groupId>junit</groupId> | ||
| 38 | <artifactId>junit</artifactId> | ||
| 39 | <version>3.8.1</version> | ||
| 40 | <scope>test</scope> | ||
| 41 | </dependency> | ||
| 42 | |||
| 43 | |||
| 44 | <dependency> | ||
| 45 | <groupId>org.emercit</groupId> | ||
| 46 | <artifactId>pckutils</artifactId> | ||
| 47 | <version>1.0</version> | ||
| 48 | </dependency> | ||
| 49 | |||
| 50 | |||
| 51 | </dependencies> | ||
| 52 | |||
| 53 | <repositories> | ||
| 54 | <!--other repositories if any--> | ||
| 55 | <repository> | ||
| 56 | <id>project.local</id> | ||
| 57 | <name>project</name> | ||
| 58 | <url>file:/opt/devtools/repo</url> | ||
| 59 | </repository> | ||
| 60 | </repositories> | ||
| 61 | |||
| 62 | |||
| 63 | |||
| 64 | </project> |
| 1 | package org.emercit.dtmanager; | ||
| 2 | |||
| 3 | |||
| 4 | |||
| 5 | import java.text.SimpleDateFormat; | ||
| 6 | import java.util.Calendar; | ||
| 7 | import java.util.Date; | ||
| 8 | import java.util.GregorianCalendar; | ||
| 9 | import java.util.TimeZone; | ||
| 10 | |||
| 11 | import org.emercit.dtmanager.service.NtpLinux; | ||
| 12 | |||
| 13 | public class App | ||
| 14 | { | ||
| 15 | public static void main( String[] args ) | ||
| 16 | { | ||
| 17 | |||
| 18 | /* | ||
| 19 | #server 0.it.pool.ntp.org iburst | ||
| 20 | #server 1.it.pool.ntp.org iburst | ||
| 21 | #server 2.it.pool.ntp.org iburst | ||
| 22 | server 3.it.pool.ntp.org iburst | ||
| 23 | |||
| 24 | restrict default nomodify nopeer | ||
| 25 | restrict 0.0.0.0 | ||
| 26 | |||
| 27 | driftfile /var/lib/ntp/ntp.drift | ||
| 28 | logfile /var/log/ntp.log | ||
| 29 | |||
| 30 | */ | ||
| 31 | /* | ||
| 32 | Calendar calendar = Calendar.getInstance(); | ||
| 33 | |||
| 34 | |||
| 35 | TimeZone timeZone = calendar.getTimeZone(); | ||
| 36 | |||
| 37 | |||
| 38 | String[] tzAll=timeZone.getAvailableIDs(); | ||
| 39 | |||
| 40 | |||
| 41 | for (String tz:tzAll) { | ||
| 42 | System.out.println(tz); | ||
| 43 | } | ||
| 44 | |||
| 45 | */ | ||
| 46 | Calendar calendar = Calendar.getInstance(); | ||
| 47 | |||
| 48 | TimeZone.setDefault(TimeZone.getTimeZone("UTC")); | ||
| 49 | |||
| 50 | // calendar.setTimeZone(TimeZone.getTimeZone("UTC")); | ||
| 51 | |||
| 52 | TimeZone timeZone = calendar.getTimeZone(); | ||
| 53 | |||
| 54 | |||
| 55 | Date date=calendar.getTime(); | ||
| 56 | String formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); | ||
| 57 | System.out.println(formattedDate); | ||
| 58 | |||
| 59 | System.out.println(timeZone.getID()); | ||
| 60 | |||
| 61 | |||
| 62 | } | ||
| 63 | } |
| 1 | package org.emercit.dtmanager.model; | ||
| 2 | |||
| 3 | |||
| 4 | import java.io.Serializable; | ||
| 5 | import java.util.Vector; | ||
| 6 | |||
| 7 | public class NtpServerBean implements Serializable { | ||
| 8 | |||
| 9 | private static final long serialVersionUID = 1L; | ||
| 10 | |||
| 11 | private String ntpserver; | ||
| 12 | |||
| 13 | public NtpServerBean() { | ||
| 14 | |||
| 15 | } | ||
| 16 | |||
| 17 | public void setNtpserver(String value) { | ||
| 18 | this.ntpserver=value; | ||
| 19 | } | ||
| 20 | |||
| 21 | public String getNtpServer() { | ||
| 22 | return ntpserver; | ||
| 23 | } | ||
| 24 | |||
| 25 | |||
| 26 | } | ||
| 27 |
| 1 | package org.emercit.dtmanager.service; | ||
| 2 | |||
| 3 | import java.io.BufferedWriter; | ||
| 4 | import java.io.File; | ||
| 5 | import java.io.FileWriter; | ||
| 6 | import java.io.IOException; | ||
| 7 | |||
| 8 | import org.emercit.pckutils.cmd.CmdExec; | ||
| 9 | |||
| 10 | |||
| 11 | public class NtpLinux implements INtp { | ||
| 12 | |||
| 13 | private CmdExec cmdexec=new CmdExec(); | ||
| 14 | |||
| 15 | public String getUseNtpServer() { | ||
| 16 | |||
| 17 | try { | ||
| 18 | |||
| 19 | return cmdexec.Run("cat /etc/ntp.conf | grep server | awk '{print $2}'").firstElement(); | ||
| 20 | |||
| 21 | }catch(Exception e) { | ||
| 22 | |||
| 23 | return null; | ||
| 24 | } | ||
| 25 | |||
| 26 | } | ||
| 27 | |||
| 28 | public boolean setUsNtpServer(String value) { | ||
| 29 | |||
| 30 | try { | ||
| 31 | File file = new File("/etc/ntp.conf"); | ||
| 32 | |||
| 33 | if (!file.exists()) { | ||
| 34 | file.createNewFile(); | ||
| 35 | } | ||
| 36 | |||
| 37 | FileWriter fw = new FileWriter(file.getAbsoluteFile()); | ||
| 38 | BufferedWriter bw = new BufferedWriter(fw); | ||
| 39 | |||
| 40 | bw.write("#Generated by DtManager"); | ||
| 41 | bw.write("\n"); | ||
| 42 | bw.write("\n"); | ||
| 43 | bw.write("server"); | ||
| 44 | bw.write(" "); | ||
| 45 | bw.write(value); | ||
| 46 | bw.write(" "); | ||
| 47 | bw.write("iburst"); | ||
| 48 | bw.write("\n"); | ||
| 49 | bw.write("\n"); | ||
| 50 | bw.write("restrict default nomodify nopeer"); | ||
| 51 | bw.write("\n"); | ||
| 52 | bw.write("restrict 0.0.0.0"); | ||
| 53 | bw.write("\n"); | ||
| 54 | bw.write("\n"); | ||
| 55 | bw.write("driftfile /var/lib/ntp/ntp.drift"); | ||
| 56 | bw.write("\n"); | ||
| 57 | bw.write("logfile /var/log/ntp.log"); | ||
| 58 | bw.write("\n"); | ||
| 59 | |||
| 60 | bw.close(); | ||
| 61 | } catch (IOException e) { | ||
| 62 | return false; | ||
| 63 | } | ||
| 64 | return true; | ||
| 65 | } | ||
| 66 | |||
| 67 | |||
| 68 | |||
| 69 | } |
| 1 | package org.emercit.DtManager; | ||
| 2 | |||
| 3 | import junit.framework.Test; | ||
| 4 | import junit.framework.TestCase; | ||
| 5 | import junit.framework.TestSuite; | ||
| 6 | |||
| 7 | /** | ||
| 8 | * Unit test for simple App. | ||
| 9 | */ | ||
| 10 | public class AppTest | ||
| 11 | extends TestCase | ||
| 12 | { | ||
| 13 | /** | ||
| 14 | * Create the test case | ||
| 15 | * | ||
| 16 | * @param testName name of the test case | ||
| 17 | */ | ||
| 18 | public AppTest( String testName ) | ||
| 19 | { | ||
| 20 | super( testName ); | ||
| 21 | } | ||
| 22 | |||
| 23 | /** | ||
| 24 | * @return the suite of tests being tested | ||
| 25 | */ | ||
| 26 | public static Test suite() | ||
| 27 | { | ||
| 28 | return new TestSuite( AppTest.class ); | ||
| 29 | } | ||
| 30 | |||
| 31 | /** | ||
| 32 | * Rigourous Test :-) | ||
| 33 | */ | ||
| 34 | public void testApp() | ||
| 35 | { | ||
| 36 | assertTrue( true ); | ||
| 37 | } | ||
| 38 | } |
-
Please register or sign in to post a comment