|
From: Gerry D. <gd...@us...> - 2002-06-11 15:50:08
|
Update of /cvsroot/swapdv/swapdv/ReplayClient
In directory usw-pr-cvs1:/tmp/cvs-serv29659/ReplayClient
Modified Files:
ReplayClient.java ReplayConnection.java
Log Message:
Changed all println()'s over the Logger.logs, added --debug switch and initial deleteShowActions
Index: ReplayClient.java
===================================================================
RCS file: /cvsroot/swapdv/swapdv/ReplayClient/ReplayClient.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- ReplayClient.java 11 Jun 2002 00:14:50 -0000 1.15
+++ ReplayClient.java 11 Jun 2002 15:50:04 -0000 1.16
@@ -116,7 +116,7 @@
c.processHeader();
Vector v = c.processBodyAsLines();
c.close();
- if (v.size()<2) System.out.println("Probably no such file");
+ if (v.size()<2) Logger.log(0, LoggerI.LEVEL_DEBUG, "Probably no such file");
return v;
} catch (Exception ex) {
ex.printStackTrace();
@@ -145,7 +145,7 @@
c.close();
result = true;
if (bytesread < 0) {
- System.out.println("< 0");
+ Logger.log(0, LoggerI.LEVEL_DEBUG, "< 0");
if (pcb != null) pcb.DownloadStopped(new Boolean(false),"File "+remotefile+" was not found on "+name);
} else {
try {
@@ -154,7 +154,7 @@
if (bytesread>=size) {
if (pcb!=null) pcb.DownloadStopped(new Boolean(true),"Copied ok");
if (bytesread>size)
- System.out.println("Warning: Copied too many bytes "+ (bytesread-size));
+ Logger.log(0, LoggerI.LEVEL_DEBUG, "Warning: Copied too many bytes "+ (bytesread-size));
} else if (pcb!=null) {
pcb.DownloadStopped(new Boolean(false),"Failed to copy entire file");
}
@@ -169,6 +169,10 @@
return result;
}
+ public boolean deleteShow(Show theShow) {
+ return deleteShow(theShow.recorded, theShow.created);
+ }
+
public boolean deleteShow(int showID, int chanID) {
try {
ReplayConnection c = new ReplayConnection(this);
@@ -177,7 +181,7 @@
c.writeRequest("http_replay_guide-delete_show?show_id="+showHex+"&channel_id="+chanHex+"=RTV4080K0000000000");
c.writeHeaders();
c.processHeader();
- System.out.println("Results "+c.processBodyAsLines());
+ Logger.log(0, LoggerI.LEVEL_DEBUG, "Results "+c.processBodyAsLines());
return true; // hmm, we don't get any status back
} catch (Exception ex) {
ex.printStackTrace();
@@ -199,7 +203,7 @@
// make sure we only download a guide if its newer than the one we have...
if (guide!=null) {
guideFilename = guide.asciiHeader.RemoteFileName;
- System.out.println("Existing guide has date "+guide.asciiHeader.RemoteFileName);
+ Logger.log(0, LoggerI.LEVEL_DEBUG, "Existing guide has date "+guide.asciiHeader.RemoteFileName);
}
c.writeRequest("http_replay_guide-get_snapshot?guide_file_name="+guideFilename+"&serial_no=RTV4080K0000000000");
c.writeHeaders();
@@ -210,7 +214,7 @@
byte[] bytes = bos.toByteArray();
if (bytes.length>=24 && new String(bytes,0,24).equals("guide_file_name=upToDate")) {
Logger.log(chan, LoggerI.LEVEL_DEBUG, "Up-to-date guide being returned");
- System.out.println("Up-to-date guide being returned");
+ Logger.log(0, LoggerI.LEVEL_DEBUG, "Up-to-date guide being returned");
return guide;
}
guide = new Guide(bytes);
Index: ReplayConnection.java
===================================================================
RCS file: /cvsroot/swapdv/swapdv/ReplayClient/ReplayConnection.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ReplayConnection.java 8 Jun 2002 00:49:34 -0000 1.4
+++ ReplayConnection.java 11 Jun 2002 15:50:04 -0000 1.5
@@ -48,11 +48,11 @@
protected ReplayConnection(ReplayClient client) throws IOException {
c = client;
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Connecting to "+c.ipAddr+":"+c.port+"..");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Connecting to "+c.ipAddr+":"+c.port+"..");
s = new Socket(c.ipAddr,c.port);
s.setSoTimeout(5 * 60 * 1000); // TODO: make this configurable
os = s.getOutputStream();
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Connected to "+c.ipAddr+":"+c.port);
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Connected to "+c.ipAddr+":"+c.port);
nl[0]=13;
nl[1]=10;
}
@@ -62,7 +62,7 @@
int d = is.available();
while (d>0) {
if (d>buf.length) d = buf.length;
- //System.out.println("emptying "+d+" bytes from stream");
+ //Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "emptying "+d+" bytes from stream");
is.read(buf,0,d);
d = is.available();
}
@@ -79,23 +79,23 @@
}
protected void writeHeaders() {
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Sending HTTP headers");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Sending HTTP headers");
httpLine("Authorization: Basic Uk5TQmFzaWM6QTd4KjgtUXQ=");
httpLine("User-Agent: Replay-HTTPFS/1");
httpLine("Host: "+c.ipAddr+":"+c.port);
httpLine("Accept-Encoding: gzip");
httpLine("");
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Sent HTTP headers");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Sent HTTP headers");
try { os.flush(); } catch (Exception ex) {}
}
protected void writeRequest(String req) {
httpLine("GET http://"+c.ipAddr+":"+c.port+"/"+req+" HTTP/1.1");
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Sent HTTP request");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Sent HTTP request");
}
protected void processHeader() {
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processing http header");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processing http header");
String line = null;
try {
is = new ThrottledInputStream(s.getInputStream());
@@ -113,11 +113,11 @@
}
if (!isSwapDV)
is.setRate(ThrottledInputStream.replayThrottledRate);
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processed http header");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processed http header");
}
protected Vector processBodyAsLines() {
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processing response body into lines");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processing response body into lines");
Vector v = new Vector();
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
@@ -127,7 +127,7 @@
while (dis.available()>0) {
v.addElement(dis.readLine());
}
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processed response body ok");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processed response body ok");
} catch (Exception ex) {
ex.printStackTrace();
Logger.log(c.chan, LoggerI.LEVEL_ERR, ex.getMessage());
@@ -136,14 +136,14 @@
}
protected String processBodyAsString() {
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processing response body into string");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processing response body into string");
String s = null;
try {
ByteArrayOutputStream bos = new ByteArrayOutputStream();
double bytesread = processBodyToStream(bos,null);
bos.close();
s = new String(bos.toByteArray());
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processed response body ok");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processed response body ok");
} catch (Exception ex) {
ex.printStackTrace();
Logger.log(c.chan, LoggerI.LEVEL_ERR, ex.getMessage());
@@ -163,7 +163,7 @@
byte tmp[];
protected double processBodyToStream(OutputStream fos, ProgressCallback pcb) {
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processing response body to file");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processing response body to file");
double total = 0;
int amt_read = 0;
byte[] buffer = new byte[1024*32*8];
@@ -208,7 +208,7 @@
//cb.ReplayClientMessage("Getting chunk "+cnum+" ("+chunklen+" bytes)"); cnum++;
}
emptyStream();
- Logger.log(c.chan, LoggerI.LEVEL_INFO, "Processed response body ok");
+ Logger.log(c.chan, LoggerI.LEVEL_DEBUG, "Processed response body ok");
if (pcb != null) pcb.StatusChange("Processed body");
} catch (Exception ex) {
pcb.DownloadStopped(new Boolean(false),ex.getMessage());
|