Skip to content

Commit 1af2c88

Browse files
authored
Update send.py
add new json format
1 parent 8da7366 commit 1af2c88

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/send.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import requests
66
import subprocess
7-
import glob, os
7+
import glob, os, json, datetime
88

99
import base64
1010
from io import BytesIO
@@ -46,7 +46,7 @@ def show_window(self):
4646
self.textview.set_size_request(400, 200)
4747
self.textview.set_wrap_mode(Gtk.WrapMode.WORD)
4848
textbuffer = self.textview.get_buffer()
49-
textbuffer.set_text(_("Start typing your note here"))
49+
textbuffer.set_text(_(""))
5050

5151
label = Gtk.Label(_("Note:"))
5252
label.set_direction(Gtk.TextDirection.LTR)
@@ -83,19 +83,23 @@ def on_send_click(self, button):
8383
hostname = controls.execute("hostname")
8484
username = controls.execute("whoami")
8585

86+
8687
list_of_files = glob.glob(summary.MAINDIR+'ss/*')
8788
latest_file = max(list_of_files, key=os.path.getctime)
8889

89-
data = {
90+
data = []
91+
data.append({
9092
"machine_name": hostname,
9193
"username": username,
9294
"note": text,
9395
"filename": latest_file
94-
}
96+
})
97+
98+
with open(summary.MAINDIR + "ss/main.json", "a") as outfile:
99+
json.dump(data, outfile)
95100

96101
file_object = open(summary.MAINDIR + "ss/main.json", 'a')
97102
file_object.write("\n")
98-
file_object.write(str(data))
99103
file_object.close()
100104

101105
# create new script that handles all api calls

0 commit comments

Comments
 (0)