use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project gocd by gocd.
the class BuildLogElement method setBuildLogHeader.
public Element setBuildLogHeader(String execCommand) {
Element target = new Element("target");
target.setAttribute("name", "exec");
build.addContent(target);
buildTask = new Element("task");
buildTask.setAttribute("name", execCommand);
target.addContent(buildTask);
return buildTask;
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project gocd by gocd.
the class BuildWork method execute.
private JobResult execute(EnvironmentVariableContext environmentVariableContext) {
Date now = new Date();
// collect project information
// TODO - #2409
buildLog.addContent(new Element("info"));
JobResult result = builders.build(environmentVariableContext);
goPublisher.reportCompleting(result);
try {
buildLog.writeLogFile(now);
} catch (IOException e) {
throw bomb("Failed to write log file", e);
}
buildLog.reset();
return result;
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project gocd by gocd.
the class GoControlLog method writeLogFile.
/**
* Writes the current build log to the appropriate directory and filename.
*/
public void writeLogFile(Date now) throws IOException {
String logFilename = decideLogfileName(now);
// Add the logDir as an info element
Element logDirElement = new Element("property");
logDirElement.setAttribute("name", "logdir");
logDirElement.setAttribute("value", new File(logDir).getAbsolutePath());
buildLog.getChild("info").addContent(logDirElement);
// Add the logFile as an info element
Element logFileElement = new Element("property");
logFileElement.setAttribute("name", "logfile");
logFileElement.setAttribute("value", logFilename);
buildLog.getChild("info").addContent(logFileElement);
File logfile = new File(logDir, logFilename);
if (LOG.isDebugEnabled()) {
LOG.debug("Writing log file [" + logfile.getAbsolutePath() + "]");
}
writeLogFile(logfile, buildLog);
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project AnimeTaste by daimajia.
the class M3U8Mission method run.
@Override
public void run() {
notifyStart();
BufferedInputStream in = null;
FileOutputStream out = null;
HttpURLConnection httpURLConnection;
try {
httpURLConnection = (HttpURLConnection) new URL(getUri()).openConnection();
in = new BufferedInputStream(httpURLConnection.getInputStream());
out = getSafeOutputStream(getSaveDir(), getSaveName());
mM3U8Playlist = Playlist.parse(in);
for (Element el : mM3U8Playlist) {
mTotalVideoDuration += el.getDuration();
}
mVideoSegmentCount = mM3U8Playlist.getElements().size();
notifyMetaDataReady();
byte[] data = new byte[1024];
int count;
int c = 0;
for (Element el : mM3U8Playlist) {
HttpURLConnection connection = (HttpURLConnection) new URL(el.getURI().toString()).openConnection();
connection.setConnectTimeout(5000);
in = new BufferedInputStream(connection.getInputStream());
while (isCanceled() == false) {
try {
count = in.read(data, 0, 1024);
if (count == -1) {
break;
}
out.write(data, 0, count);
mCurrentPartDownloaded += count;
mDownloaded += count;
notifySpeedChange();
checkPaused();
} catch (Exception e) {
//if pause download, it will makes the socket close,and stop the download.
//so we need to reopen it.
//well, maybe a big bug here, maybe cause dead cycle :( so I set a
//max open count to prevent this situation.
mReopenCount++;
if (mReopenCount > MAX_REOPEN_COUNT) {
throw new Exception("There is too much open exception.");
}
connection = (HttpURLConnection) new URL(el.getURI().toString()).openConnection();
connection.setRequestProperty("Range", "bytes=" + mCurrentPartDownloaded + "-");
connection.setDoOutput(true);
connection.setDoInput(true);
in = new BufferedInputStream(connection.getInputStream());
}
}
mCurrentPartDownloaded = 0;
mDownloadedSgementCount++;
mDownloadedVideoDuration += el.getDuration();
notifyPercentageChange();
if (isCanceled()) {
notifyCancel();
break;
}
}
if (!isCanceled()) {
notifyPercentageChange();
notifySuccess();
}
} catch (Exception e) {
notifyError(e);
} finally {
try {
if (in != null)
in.close();
if (out != null)
out.close();
} catch (Exception e) {
notifyError(e);
}
notifyFinish();
}
}
use of org.eclipse.xtext.parsetree.reconstr.bug302128.Element in project pcgen by PCGen.
the class NameGenPanel method loadRuleSet.
private RuleSet loadRuleSet(Element ruleSet) throws DataConversionException {
RuleSet rs = new RuleSet(allVars, ruleSet.getAttributeValue("title"), ruleSet.getAttributeValue("id"), ruleSet.getAttributeValue("usage"));
java.util.List<?> elements = ruleSet.getChildren();
ListIterator<?> elementsIterator = elements.listIterator();
int num = 0;
while (elementsIterator.hasNext()) {
Element child = (Element) elementsIterator.next();
String elementName = child.getName();
if (elementName.equals("CATEGORY")) {
loadCategory(child, rs);
} else if (elementName.equals("RULE")) {
rs.add(loadRule(child, rs.getId() + num));
}
num++;
}
return rs;
}
Aggregations