use of com.github.mob41.osumer.debug.DebugDump in project osumer by mob41.
the class Main method runUi.
private static void runUi(Configuration config, String[] args, ArgParser ap, IDaemon d) {
IUI ui = null;
try {
// Contact the ui via RMI
ui = (IUI) Naming.lookup("rmi://localhost:46727/ui");
} catch (Exception e) {
}
if (ui == null) {
try {
Runtime.getRuntime().exec("\"" + OsumerNative.getProgramFiles() + "\\osumer2\\osumer-ui.exe\"");
} catch (IOException e) {
e.printStackTrace();
DumpManager.addDump(new DebugDump(null, "Check if \"ui\" is null", "Execute osumer-ui.exe", "Initialize \"c\" as 0", "Could not start UI. Terminating", false, e));
DumpManager.forceMetricsReport();
JOptionPane.showMessageDialog(null, "Could not start UI. For more details, check dump. Terminating:\n" + e, "osumer launcher Error", JOptionPane.ERROR_MESSAGE);
System.exit(-1);
return;
}
int c = 0;
while (c < 20) {
try {
// Contact the ui via RMI
ui = (IUI) Naming.lookup("rmi://localhost:46727/ui");
} catch (Exception e) {
}
try {
Thread.sleep(50);
} catch (InterruptedException e) {
break;
}
c++;
}
}
if (ui == null) {
DumpManager.addDump(new DebugDump(null, "(While-loop) Look up UI RMI", "Check if \\\"ui\\\" is null", "Try to wake up UI", false, "Could not connect to UI. Terminating"));
DumpManager.forceMetricsReport();
JOptionPane.showMessageDialog(null, "Could not connect to UI. For more details, check dump. Terminating", "osumer launcher Error", JOptionPane.ERROR_MESSAGE);
System.exit(-1);
return;
}
try {
ui.wake();
} catch (RemoteException e) {
e.printStackTrace();
DumpManager.addDump(new DebugDump(null, "Check if \\\\\\\"ui\\\\\\\" is null", "Try to wake up UI", "End of runUi()", "Could not connect or wake UI", false, e));
DumpManager.forceMetricsReport();
JOptionPane.showMessageDialog(null, "Could not connect or wake UI. For more details, check dump:\n" + e, "osumer launcher Error", JOptionPane.ERROR_MESSAGE);
System.exit(-1);
return;
}
}
use of com.github.mob41.osumer.debug.DebugDump in project osumer by mob41.
the class URLDownloader method run.
@Override
public void run() {
RandomAccessFile file = null;
InputStream in = null;
try {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestProperty("Range", "bytes=" + downloaded + "-");
conn.connect();
if (conn.getResponseCode() / 100 != 2) {
error();
}
int len = conn.getContentLength();
if (len < 1) {
error();
}
if (size == -1) {
size = len;
reportState();
}
file = new RandomAccessFile(folder + "\\" + fileName, "rw");
file.seek(downloaded);
in = conn.getInputStream();
while (status == DOWNLOADING) {
if (size == downloaded) {
break;
}
byte[] buffer = size - downloaded > MAX_BUFFER_SIZE ? new byte[MAX_BUFFER_SIZE] : new byte[size - downloaded];
int read = in.read(buffer);
if (read == -1) {
break;
}
file.write(buffer, 0, read);
downloaded += read;
reportState();
}
if (status == DOWNLOADING) {
if (file != null) {
try {
file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
status = COMPLETED;
reportState();
}
} catch (IOException e) {
DumpManager.addDump(dump = new DebugDump(null, "(Try&catch try)", "Error reporting and debug dump", "(Try&catch finally)", "Error when downloading", false, e));
error();
} finally {
if (file != null) {
try {
file.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (in != null) {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
use of com.github.mob41.osumer.debug.DebugDump in project osumer by mob41.
the class AfterSoundAction method run.
@Override
public void run(Queue queue) {
Thread thread = new Thread(new Runnable() {
public void run() {
try {
Media m = new Media(new File(config.getToneAfterDownloadPath()).toURI().toString());
MediaPlayer mp = new MediaPlayer(m);
mp.play();
} catch (Exception e) {
e.printStackTrace();
DumpManager.addDump(new DebugDump(null, "---", "Play after download sound", "---", "Error occurred when trying to play sound", false, e));
}
}
});
thread.setDaemon(true);
thread.start();
}
use of com.github.mob41.osumer.debug.DebugDump in project osumer by mob41.
the class BeforeSoundAction method run.
@Override
public void run(Queue queue) {
Thread thread = new Thread(new Runnable() {
public void run() {
try {
Media m = new Media(new File(config.getToneBeforeDownloadPath()).toURI().toString());
MediaPlayer mp = new MediaPlayer(m);
mp.play();
} catch (Exception e) {
e.printStackTrace();
DumpManager.addDump(new DebugDump(null, "---", "Play before download sound", "---", "Error occurred when trying to play sound", false, e));
}
}
});
thread.setDaemon(true);
thread.start();
}
use of com.github.mob41.osumer.debug.DebugDump in project osumer by mob41.
the class UpdaterRunAction method run.
@Override
public void run(Queue queue) {
try {
System.out.println("Starting: \"" + filePath + "\"");
Runtime.getRuntime().exec("cmd.exe /c \"" + filePath + "\" -install");
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
System.exit(0);
return;
} catch (IOException e1) {
e1.printStackTrace();
DebugDump dump = new DebugDump(null, "(If[openFile] scope) (UI) Set status to lblStatus", "(Try scope) Open file loc using Desktop.getDesktop.open()", "(Try scope) Sleep 2000 ms (2 sec)", "Unable to open file", false, e1);
DumpManager.addDump(dump);
// TODO
/*
ErrorDumpDialog dialog = new ErrorDumpDialog(dump);
dialog.setModal(true);
dialog.setVisible(true);
*/
}
}
Aggregations