Skip to content
Extraits de code Groupes Projets
Valider a847bf0f rédigé par Miryuni's avatar Miryuni
Parcourir les fichiers

Added colors on the scripts

parent 55373b42
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -141,6 +141,7 @@ do
convert "$slug/tmp/$f.$type" -resize "128x128" "$slug/tmp/size"
width=$(identify -format "%w" "$slug/tmp/size"[0])> /dev/null
height=$(identify -format "%h" "$slug/tmp/size"[0])> /dev/null
# Appending to json
echo -n "{\"body\":\"$f\",\"info\":{\"mimetype\":\"image/$type\",\"h\":$height,\"w\":$width,\"thumbnail_url\":\"$mxc\"},\"msgtype\":\"m.sticker\",\"url\":\"$mxc\",\"id\":\"$packname-$f\"}" >> "$slug/$slug.json"
first=","
......
import json
import sys
from colorama import Fore, Back, Style
# Check the arguments
# Pack is updated only if index and description are precised
update = False
if len(sys.argv) <= 1 or len(sys.argv) == 3:
print("Usage : python updatePack.py pack.json [sticker_index] [new_description]")
print("Usage : python updatePacks.py pack.json [sticker_index] [new_description]")
exit(1)
elif len(sys.argv) > 3:
update = True
......@@ -23,9 +24,9 @@ if update == False:
# Print the number of stickers in this pack
print("There are " +str(nb_stickers) + " stickers in this pack: ")
for i in range(nb_stickers):
print(str(i+1) + ". " + json_pack['stickers'][i]['body'])
print("To update one of them type:")
print("python updatePack.py " + sys.argv[1] + " sticker_index 'new_description'")
print("\t"+str(i+1) + ". " + json_pack['stickers'][i]['body'])
print("To update one of them replace the red arguments:")
print(Fore.CYAN +Style.BRIGHT + "python " +Style.RESET_ALL+ "updatePacks.py " + sys.argv[1] + Fore.RED + Style.BRIGHT+" sticker_index 'new_description'")
exit(0)
# Informations
......@@ -41,8 +42,10 @@ elif sticker_index == 0:
else:
json_pack['stickers'][sticker_index-1]['body'] = new_body
# Print the body of all the stickers
print(Fore.GREEN + 'Updated!')
print("New sticker pack:")
for i in range(nb_stickers):
print(str(i+1) + ". " + json_pack['stickers'][i]['body'])
print("\t "+str(i+1) + ". " + json_pack['stickers'][i]['body'])
out_file = open(sys.argv[1], 'w')
json.dump(json_pack, out_file, indent = 3)
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter