Ajout du chemin vers weight-cli pour pouvoir lancer le soft depuis partout
This commit is contained in:
parent
77dfe1b76a
commit
3b241c9891
@ -16,5 +16,5 @@ set xtics nomirror
|
|||||||
set xrange [*:*]
|
set xrange [*:*]
|
||||||
set datafile separator '|'
|
set datafile separator '|'
|
||||||
f(x) = 86.41099999999999
|
f(x) = 86.41099999999999
|
||||||
plot 'data.csv' using 3:1 w dots title '', f(x) lc 'red' w dots title 'bmi max'
|
plot '/home/guyotv/Documents/Echange/weight-cli/data_perso.csv' using 3:1 w dots title '', f(x) lc 'red' w dots title 'bmi max'
|
||||||
#pause -1 'En attente de RETURN'
|
#pause -1 'En attente de RETURN'
|
||||||
|
@ -29,9 +29,15 @@ from subprocess import Popen, PIPE
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import gettext
|
import gettext
|
||||||
#gettext.bindtextdomain('base', 'locale/en/LC_MESSAGES/base.mo')
|
#gettext.bindtextdomain('base', 'locale/en/LC_MESSAGES/base.mo')
|
||||||
|
#gettext.bindtextdomain('base', '.')
|
||||||
#gettext.textdomain('base')
|
#gettext.textdomain('base')
|
||||||
|
gettext.find('base')
|
||||||
# Voir : https://docs.python.org/fr/3/library/gettext.html
|
# Voir : https://docs.python.org/fr/3/library/gettext.html
|
||||||
en = gettext.translation('base', localedir='locale/', languages=['en'])
|
origindir = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
localedir = os.path.dirname(os.path.abspath(__file__))+"/locale/"
|
||||||
|
#print(localedir)
|
||||||
|
en = gettext.translation('base', localedir=localedir, languages=['en'])
|
||||||
|
#en = gettext.translation('base', localedir='locale', languages=['en'])
|
||||||
en.install()
|
en.install()
|
||||||
_ = en.gettext # english
|
_ = en.gettext # english
|
||||||
# fr = gettext.translation('base', localedir='locale/', languages=['fr'])
|
# fr = gettext.translation('base', localedir='locale/', languages=['fr'])
|
||||||
@ -67,16 +73,16 @@ weight-cli --help or weight-cli -h
|
|||||||
|
|
||||||
def save_file_data():
|
def save_file_data():
|
||||||
""" Saving the data file name """
|
""" Saving the data file name """
|
||||||
f = open("Fonctionnel.txt", "r")
|
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
linenum = 0
|
linenum = 0
|
||||||
for row in contents:
|
for row in contents:
|
||||||
if row.split(' ',1)[0] == 'plot':
|
if row.split(' ',1)[0] == 'plot':
|
||||||
contents.insert(linenum, "plot '"+args.data+"' using 3:1 w dots title '', f(x) lc 'red' w dots title 'bmi max'\n")
|
contents.insert(linenum, "plot '"+origindir+'/'+str(args.data)+"' using 3:1 w dots title '', f(x) lc 'red' w dots title 'bmi max'\n")
|
||||||
del(contents[linenum+1])
|
del(contents[linenum+1])
|
||||||
linenum += 1
|
linenum += 1
|
||||||
f = open("Fonctionnel.txt", "w")
|
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||||
contents = "".join(contents)
|
contents = "".join(contents)
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.close()
|
f.close()
|
||||||
@ -92,7 +98,7 @@ def save_mesure():
|
|||||||
puts("-the identifier : {ide}".format(ide=args.id))
|
puts("-the identifier : {ide}".format(ide=args.id))
|
||||||
puts("-your comment : {comment}".format(comment=args.comment))
|
puts("-your comment : {comment}".format(comment=args.comment))
|
||||||
puts("-other : {other}".format(other=args.other))
|
puts("-other : {other}".format(other=args.other))
|
||||||
with open(str(args.data), 'a', newline='\n') as csvfile:
|
with open(origindir+'/'+str(args.data), 'a', newline='\n') as csvfile:
|
||||||
weightwriter = csv.writer(csvfile, delimiter='|', quotechar='"', quoting=csv.QUOTE_MINIMAL)
|
weightwriter = csv.writer(csvfile, delimiter='|', quotechar='"', quoting=csv.QUOTE_MINIMAL)
|
||||||
weightwriter.writerow([str(args.weight), \
|
weightwriter.writerow([str(args.weight), \
|
||||||
str(args.type), \
|
str(args.type), \
|
||||||
@ -103,7 +109,7 @@ def save_mesure():
|
|||||||
|
|
||||||
def read_measures():
|
def read_measures():
|
||||||
""" Display of all measures """
|
""" Display of all measures """
|
||||||
data_file = open(str(args.data), 'r')
|
data_file = open(origindir+'/'+str(args.data), 'r')
|
||||||
data = csv.reader(data_file, delimiter='|')
|
data = csv.reader(data_file, delimiter='|')
|
||||||
linenum = 0
|
linenum = 0
|
||||||
for row in data:
|
for row in data:
|
||||||
@ -121,33 +127,33 @@ def read_measures():
|
|||||||
|
|
||||||
def remove_measure():
|
def remove_measure():
|
||||||
""" Remove a measure """
|
""" Remove a measure """
|
||||||
f = open(args.data, "r")
|
f = open(origindir+'/'+str(args.data), "r")
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
# remove the line item from list, by line number, starts from 0
|
# remove the line item from list, by line number, starts from 0
|
||||||
store_temp = str(args.remove)+' '+contents[args.remove]
|
store_temp = str(args.remove)+' '+contents[args.remove]
|
||||||
g = open('remove.txt', "w")
|
g = open(origindir+'/remove.txt', "w")
|
||||||
g.write(str(store_temp))
|
g.write(str(store_temp))
|
||||||
g.close()
|
g.close()
|
||||||
contents.pop(args.remove)
|
contents.pop(args.remove)
|
||||||
|
|
||||||
f = open(args.data, "w")
|
f = open(origindir+'/'+str(args.data), "w")
|
||||||
contents = "".join(contents)
|
contents = "".join(contents)
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def undo_remove():
|
def undo_remove():
|
||||||
""" Undo remove the last line removed """
|
""" Undo remove the last line removed """
|
||||||
f = open(args.data, "r")
|
f = open(origindir+'/'+str(args.data), "r")
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
g = open('remove.txt', 'r')
|
g = open(origindir+'/remove.txt', 'r')
|
||||||
store_temp = g.readline().split(' ',1)
|
store_temp = g.readline().split(' ',1)
|
||||||
g.close()
|
g.close()
|
||||||
# insert the line item from list, by its line number
|
# insert the line item from list, by its line number
|
||||||
contents.insert(int(store_temp[0]), store_temp[1])
|
contents.insert(int(store_temp[0]), store_temp[1])
|
||||||
|
|
||||||
f = open(args.data, "w")
|
f = open(origindir+'/'+str(args.data), "w")
|
||||||
contents = "".join(contents)
|
contents = "".join(contents)
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.close()
|
f.close()
|
||||||
@ -157,7 +163,7 @@ def plot_graph():
|
|||||||
if args.dates != None:
|
if args.dates != None:
|
||||||
print(args.dates)
|
print(args.dates)
|
||||||
# set xrange [*:*]
|
# set xrange [*:*]
|
||||||
f = open("Fonctionnel.txt", "r")
|
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
linenum = 0
|
linenum = 0
|
||||||
@ -173,12 +179,12 @@ def plot_graph():
|
|||||||
contents.insert(linenum, ligne)
|
contents.insert(linenum, ligne)
|
||||||
del(contents[linenum+1])
|
del(contents[linenum+1])
|
||||||
linenum += 1
|
linenum += 1
|
||||||
f = open("Fonctionnel.txt", "w")
|
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||||
contents = "".join(contents)
|
contents = "".join(contents)
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.close()
|
f.close()
|
||||||
else:
|
else:
|
||||||
f = open("Fonctionnel.txt", "r")
|
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
linenum = 0
|
linenum = 0
|
||||||
@ -188,23 +194,23 @@ def plot_graph():
|
|||||||
contents.insert(linenum, "set xrange [*:*]\n")
|
contents.insert(linenum, "set xrange [*:*]\n")
|
||||||
del(contents[linenum+1])
|
del(contents[linenum+1])
|
||||||
linenum += 1
|
linenum += 1
|
||||||
f = open("Fonctionnel.txt", "w")
|
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||||
contents = "".join(contents)
|
contents = "".join(contents)
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.close()
|
f.close()
|
||||||
#process = Popen(['gnuplot', 'Fonctionnel.txt'], stdout=PIPE, stderr=PIPE)
|
#process = Popen(['gnuplot', 'Fonctionnel.txt'], stdout=PIPE, stderr=PIPE)
|
||||||
process = Popen(['gnuplot', 'Fonctionnel.txt'])#, stdout=PIPE, stderr=PIPE)
|
process = Popen(['gnuplot', origindir+'/Fonctionnel.txt'])#, stdout=PIPE, stderr=PIPE)
|
||||||
stdout, stderr = process.communicate()
|
stdout, stderr = process.communicate()
|
||||||
#print(stdout)
|
#print(stdout)
|
||||||
|
|
||||||
def save_size():
|
def save_size():
|
||||||
print(bmi_weight_max())
|
print(bmi_weight_max())
|
||||||
""" Store the size """
|
""" Store the size """
|
||||||
f = open('personal.txt', "w")
|
f = open(origindir+'/personal.txt', "w")
|
||||||
f.write(str(args.size))
|
f.write(str(args.size))
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
f = open("Fonctionnel.txt", "r")
|
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||||
contents = f.readlines()
|
contents = f.readlines()
|
||||||
f.close()
|
f.close()
|
||||||
linenum = 0
|
linenum = 0
|
||||||
@ -214,20 +220,20 @@ def save_size():
|
|||||||
contents.insert(linenum, "f(x) = "+str(bmi_weight_max())+"\n")
|
contents.insert(linenum, "f(x) = "+str(bmi_weight_max())+"\n")
|
||||||
del(contents[linenum+1])
|
del(contents[linenum+1])
|
||||||
linenum += 1
|
linenum += 1
|
||||||
f = open("Fonctionnel.txt", "w")
|
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||||
contents = "".join(contents)
|
contents = "".join(contents)
|
||||||
f.write(contents)
|
f.write(contents)
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def tests_subproc():
|
def tests_subproc():
|
||||||
""" Test of the subprocess module """
|
""" Test of the subprocess module """
|
||||||
process = Popen(['cat', 'data2.csv'], stdout=PIPE, stderr=PIPE)
|
process = Popen(['cat', origindir+'/data2.csv'], stdout=PIPE, stderr=PIPE)
|
||||||
stdout, stderr = process.communicate()
|
stdout, stderr = process.communicate()
|
||||||
print(stdout)
|
print(stdout)
|
||||||
|
|
||||||
def bmi(the_weight):
|
def bmi(the_weight):
|
||||||
""" Return the BMI for a given size """
|
""" Return the BMI for a given size """
|
||||||
f = open('personal.txt', "r")
|
f = open(origindir+'/personal.txt', "r")
|
||||||
the_size = float(f.read())
|
the_size = float(f.read())
|
||||||
f.close()
|
f.close()
|
||||||
bmi = the_weight / pow(the_size, 2)
|
bmi = the_weight / pow(the_size, 2)
|
||||||
@ -235,7 +241,7 @@ def bmi(the_weight):
|
|||||||
|
|
||||||
def bmi_weight_max():
|
def bmi_weight_max():
|
||||||
""" Return the weight for BMI max """
|
""" Return the weight for BMI max """
|
||||||
f = open('personal.txt', "r")
|
f = open(origindir+'/personal.txt', "r")
|
||||||
the_size = float(f.read())
|
the_size = float(f.read())
|
||||||
f.close()
|
f.close()
|
||||||
weight_max = 29.9 * pow(the_size, 2)
|
weight_max = 29.9 * pow(the_size, 2)
|
||||||
@ -253,7 +259,7 @@ texte = _('A script to manage your weight in command line.')
|
|||||||
parser.description=texte
|
parser.description=texte
|
||||||
# Creating arguments
|
# Creating arguments
|
||||||
parser.add_argument('-da', '--data',
|
parser.add_argument('-da', '--data',
|
||||||
default='data.csv',
|
default=origindir+'/data.csv',
|
||||||
help=_('optional : file data')
|
help=_('optional : file data')
|
||||||
)
|
)
|
||||||
parser.add_argument('-s', '--size',
|
parser.add_argument('-s', '--size',
|
||||||
|
Loading…
Reference in New Issue
Block a user