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 datafile separator '|'
|
||||
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'
|
||||
|
@ -29,9 +29,15 @@ from subprocess import Popen, PIPE
|
||||
import numpy as np
|
||||
import gettext
|
||||
#gettext.bindtextdomain('base', 'locale/en/LC_MESSAGES/base.mo')
|
||||
#gettext.bindtextdomain('base', '.')
|
||||
#gettext.textdomain('base')
|
||||
gettext.find('base')
|
||||
# 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.gettext # english
|
||||
# fr = gettext.translation('base', localedir='locale/', languages=['fr'])
|
||||
@ -67,16 +73,16 @@ weight-cli --help or weight-cli -h
|
||||
|
||||
def save_file_data():
|
||||
""" Saving the data file name """
|
||||
f = open("Fonctionnel.txt", "r")
|
||||
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
linenum = 0
|
||||
for row in contents:
|
||||
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])
|
||||
linenum += 1
|
||||
f = open("Fonctionnel.txt", "w")
|
||||
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
@ -92,7 +98,7 @@ def save_mesure():
|
||||
puts("-the identifier : {ide}".format(ide=args.id))
|
||||
puts("-your comment : {comment}".format(comment=args.comment))
|
||||
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.writerow([str(args.weight), \
|
||||
str(args.type), \
|
||||
@ -103,7 +109,7 @@ def save_mesure():
|
||||
|
||||
def read_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='|')
|
||||
linenum = 0
|
||||
for row in data:
|
||||
@ -121,33 +127,33 @@ def read_measures():
|
||||
|
||||
def remove_measure():
|
||||
""" Remove a measure """
|
||||
f = open(args.data, "r")
|
||||
f = open(origindir+'/'+str(args.data), "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
# remove the line item from list, by line number, starts from 0
|
||||
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.close()
|
||||
contents.pop(args.remove)
|
||||
|
||||
f = open(args.data, "w")
|
||||
f = open(origindir+'/'+str(args.data), "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
|
||||
def undo_remove():
|
||||
""" Undo remove the last line removed """
|
||||
f = open(args.data, "r")
|
||||
f = open(origindir+'/'+str(args.data), "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
g = open('remove.txt', 'r')
|
||||
g = open(origindir+'/remove.txt', 'r')
|
||||
store_temp = g.readline().split(' ',1)
|
||||
g.close()
|
||||
# insert the line item from list, by its line number
|
||||
contents.insert(int(store_temp[0]), store_temp[1])
|
||||
|
||||
f = open(args.data, "w")
|
||||
f = open(origindir+'/'+str(args.data), "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
@ -157,7 +163,7 @@ def plot_graph():
|
||||
if args.dates != None:
|
||||
print(args.dates)
|
||||
# set xrange [*:*]
|
||||
f = open("Fonctionnel.txt", "r")
|
||||
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
linenum = 0
|
||||
@ -173,12 +179,12 @@ def plot_graph():
|
||||
contents.insert(linenum, ligne)
|
||||
del(contents[linenum+1])
|
||||
linenum += 1
|
||||
f = open("Fonctionnel.txt", "w")
|
||||
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
else:
|
||||
f = open("Fonctionnel.txt", "r")
|
||||
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
linenum = 0
|
||||
@ -188,23 +194,23 @@ def plot_graph():
|
||||
contents.insert(linenum, "set xrange [*:*]\n")
|
||||
del(contents[linenum+1])
|
||||
linenum += 1
|
||||
f = open("Fonctionnel.txt", "w")
|
||||
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
#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()
|
||||
#print(stdout)
|
||||
|
||||
def save_size():
|
||||
print(bmi_weight_max())
|
||||
""" Store the size """
|
||||
f = open('personal.txt', "w")
|
||||
f = open(origindir+'/personal.txt', "w")
|
||||
f.write(str(args.size))
|
||||
f.close()
|
||||
|
||||
f = open("Fonctionnel.txt", "r")
|
||||
f = open(origindir+"/Fonctionnel.txt", "r")
|
||||
contents = f.readlines()
|
||||
f.close()
|
||||
linenum = 0
|
||||
@ -214,20 +220,20 @@ def save_size():
|
||||
contents.insert(linenum, "f(x) = "+str(bmi_weight_max())+"\n")
|
||||
del(contents[linenum+1])
|
||||
linenum += 1
|
||||
f = open("Fonctionnel.txt", "w")
|
||||
f = open(origindir+"/Fonctionnel.txt", "w")
|
||||
contents = "".join(contents)
|
||||
f.write(contents)
|
||||
f.close()
|
||||
|
||||
def tests_subproc():
|
||||
""" 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()
|
||||
print(stdout)
|
||||
|
||||
def bmi(the_weight):
|
||||
""" Return the BMI for a given size """
|
||||
f = open('personal.txt', "r")
|
||||
f = open(origindir+'/personal.txt', "r")
|
||||
the_size = float(f.read())
|
||||
f.close()
|
||||
bmi = the_weight / pow(the_size, 2)
|
||||
@ -235,7 +241,7 @@ def bmi(the_weight):
|
||||
|
||||
def bmi_weight_max():
|
||||
""" Return the weight for BMI max """
|
||||
f = open('personal.txt', "r")
|
||||
f = open(origindir+'/personal.txt', "r")
|
||||
the_size = float(f.read())
|
||||
f.close()
|
||||
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
|
||||
# Creating arguments
|
||||
parser.add_argument('-da', '--data',
|
||||
default='data.csv',
|
||||
default=origindir+'/data.csv',
|
||||
help=_('optional : file data')
|
||||
)
|
||||
parser.add_argument('-s', '--size',
|
||||
|
Loading…
Reference in New Issue
Block a user