Skip to content

Commit

Permalink
Update send.py
Browse files Browse the repository at this point in the history
add new json format
  • Loading branch information
aliorhun authored Oct 8, 2020
1 parent 8da7366 commit 1af2c88
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/send.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import requests
import subprocess
import glob, os
import glob, os, json, datetime

import base64
from io import BytesIO
Expand Down Expand Up @@ -46,7 +46,7 @@ def show_window(self):
self.textview.set_size_request(400, 200)
self.textview.set_wrap_mode(Gtk.WrapMode.WORD)
textbuffer = self.textview.get_buffer()
textbuffer.set_text(_("Start typing your note here"))
textbuffer.set_text(_(""))

label = Gtk.Label(_("Note:"))
label.set_direction(Gtk.TextDirection.LTR)
Expand Down Expand Up @@ -83,19 +83,23 @@ def on_send_click(self, button):
hostname = controls.execute("hostname")
username = controls.execute("whoami")


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

data = {
data = []
data.append({
"machine_name": hostname,
"username": username,
"note": text,
"filename": latest_file
}
})

with open(summary.MAINDIR + "ss/main.json", "a") as outfile:
json.dump(data, outfile)

file_object = open(summary.MAINDIR + "ss/main.json", 'a')
file_object.write("\n")
file_object.write(str(data))
file_object.close()

# create new script that handles all api calls
Expand Down

0 comments on commit 1af2c88

Please sign in to comment.