Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
A small script that extracts skeinforge settings from a profile folder and prints out a html report
#!/usr/bin/env groovy
import groovy.xml.MarkupBuilder
// 1st param is profile directory, or use default given below
def settingsPath = (this.args.length > 0)? this.args[0] : "C:\\Users\\Gary Hodgson\\Desktop\\skeinforge settings\\profiles\\extrusion\\Mendeln05l04PLA"
list= []
new File(settingsPath).eachFileRecurse{ list<< it }
settingsMap = [:]
list.each
{ f1 ->
valMap = [:]
f1.eachLine{ line, lineNo ->
if (lineNo >= 5)
{
pair = line.split('\t')
if (pair.length == 2)
{
valMap[pair[0]] = pair[1]
}
}
}
settingsMap[f1.name] = valMap
}
def now = new Date()
def writer = new StringWriter()
def build = new MarkupBuilder(writer)
build.html {
head {
title("Skeinforge Settings: " + now)
style(type:"text/css", '''
table, td {
border: 1px solid Black;
border-collapse: collapse;
}
th {
background-color: lightgrey;
}
''')
}
body
{
div(id:"skeingforge_settings")
{
h1("Skeinforge Settings: " + now)
hr()
div(id:"important_settings")
{
table(cellpadding:2,cellspacing:0)
{
tr
{
td("Layer Thickness (mm): ")
td(settingsMap['carve.csv']."Layer Thickness (mm):")
}
tr
{
td("Perimeter Width over Thickness (ratio): ")
td(settingsMap['carve.csv']."Perimeter Width over Thickness (ratio):")
}
tr
{
td("Infill Solidity (ratio): ")
td(settingsMap['fill.csv']."Infill Solidity (ratio):")
}
tr
{
td("Feed Rate (mm/s): ")
td(settingsMap['speed.csv']."Feed Rate (mm/s):")
}
tr
{
td("Flow Rate Setting (float): ")
td(settingsMap['speed.csv']."Flow Rate Setting (float):")
}
tr
{
td("Object Next Layers Temperature (Celcius): ")
td(settingsMap['temperature.csv']."Object Next Layers Temperature (Celcius):")
}
}
}
a(href:"javascript://",onclick:"document.getElementById('more_settings').style.display = 'block'", "Show All Settings")
hr()
div(id:"more_settings",style:"display:none")
{
settingsMap.each
{ settingFileName, values ->
def settingName = settingFileName.minus(".csv")
a(href:"#$settingName", settingName)
}
table(cellpadding:2,cellspacing:0)
{
settingsMap.each
{ settingFileName, values ->
def settingName = settingFileName.minus(".csv")
tr
{
th("colspan":"2")
{
a(name:settingName, settingName)
}
}
values.each { name, value ->
tr
{
td(name)
td(value)
}
}
}
}
}
}
}
}
println writer.toString()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment