This repository has been archived by the owner on Mar 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
trelloknecht.go
131 lines (113 loc) · 3.29 KB
/
trelloknecht.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package main
import (
"time"
// "github.com/adlio/trello"
"github.com/adlio/trello"
log "github.com/sirupsen/logrus"
"github.com/denisbrodbeck/machineid"
"io/ioutil"
"os"
)
var (
configuration = map[string]string{
// pdf setings
"fontFamily": "Helvetica",
"pdfUnitStr": "mm",
"pdfDocXLen": "100.0",
"pdfDocYLen": "62.0",
"pdfMargin": "3.0",
"headLineCharsSkip": "82",
"printQrCode": "true",
"qRCodeSize": "30.0",
"qRCodePosX": "66.0",
"qRCodePosY": "25.0",
"headFontStyle": "B",
"headFontSize": "16.0",
"headTopMargin": "5.0",
"rectX0": "3.0",
"rectY0": "2.0",
"rectX1": "95.0",
"rectY1": "58.0",
// trello settings
"trelloAppKey": "",
"trelloToken": "",
"toPrintedLabelName": "PRINTME_DEVOPS",
"newLabelAfterPrint": "PRINTED",
"knechtID": "",
"trelloUserName": "kls_drucker",
"configTrelloBoardID": "someIdentifier",
"boardsToWatch": "DevOps 2020 - Board",
"configCardName": "PrintBert02 Card",
"usePrinterStatusBoard": "true",
"printFrame": "false",
"ConfigListOnBoard": "IDs",
"printerMedia": "Custom.62x100mm",
"printerOrientation": "landscape",
"printerName": "Brother_QL_700",
"tmpDirName": "",
"tmpDirPrefix": "trelloKnecht",
"numberOfCopiesPrnt": "2",
"waitIntervalSeconds": "60",
}
//utility vars
newLabelAfterPrtIDs = make(map[string]string)
boardNameByID = make(map[string]string)
listNameByID = make(map[string]string)
listIDByName = make(map[string]string)
labelIDByName = make(map[string]string)
cardByFileName = make(map[string]*trello.Card)
printedCards = make([]string, 0)
// composed vars
pdfDocDimension = []float64{}
pdfMargins = []float64{}
qRCodePos = []float64{}
blackRectPos = []float64{}
boardsToWatch = []string{}
configFile = ""
tokenFile = ""
// printer settings
)
//Resultset Json for output
type Resultset struct {
OSCommand string `json:"os.cmd"`
CommandArgs []string `json:"cmd.args"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr,omitempty"`
CmdStarttime time.Time `json:"cmd.starttime"`
CMDStoptime time.Time `json:"cmd.stoptime"`
DurationSecounds int `json:"duration.seconds"`
SuccessfullExecution bool `json:"succesful"`
ErrorStr string `json:"errorstr,omitempty"`
}
func init() {
checkCommandLineArgs()
fetchConfiguration()
configuration["ip"] = fetchIP()
fetchBoardListFromConfig()
log.Infof("IP is %v", configuration["ip"])
dir, err := ioutil.TempDir(os.TempDir(), configuration["tmpDirPrefix"])
if err != nil {
log.Fatal(err)
}
log.Debugf(dir)
configuration["tmpDirName"] = dir
id, err := machineid.ProtectedID("trelloknect")
if err != nil {
log.Fatal(err)
}
configuration["knechtID"] = id
}
func main() {
defer cleanUp(configuration["tmpDirName"])
//sleeptime, err := strconv.ad(configuration["waitIntervalSeconds"])
createIPCardOnBoard()
for {
cardList := getLabels()
pdfFileList := writeLabels(cardList)
removeLabel(cardList)
printLabels(pdfFileList)
reportPrints()
sweepOut()
time.Sleep(60 * time.Second)
}
}