From 6bf912ba61aee249c344ebbd160df0280748fa9e Mon Sep 17 00:00:00 2001 From: Lionel Date: Tue, 16 Oct 2018 15:34:08 +0200 Subject: On avance ça va. Création de errmsg.py qui regroupe les messages d'erreurs qui sont et (seront) récurrents MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- foldercreating.py | 88 ++++++++++++++++++++++++------------------------------- 1 file changed, 39 insertions(+), 49 deletions(-) (limited to 'foldercreating.py') diff --git a/foldercreating.py b/foldercreating.py index a95c169..a6fa34f 100644 --- a/foldercreating.py +++ b/foldercreating.py @@ -1,61 +1,51 @@ import subprocess import os import time - +import colorcode as clc +import errmsg as e #global foldernames -#(foldernames[0].split(' ')[0]+"-"+foldernames[0].split(' ')[2]).lower() => cirque-cilaos . ce formating sera pratique pour le site web +#(foldernames[0].split(' ')[0]+"-"+foldernames[0].split(' ')[2]).lower() => cirque-cilaos . ce formating sera pratique lors de la récupération sur site web thehome=os.path.expanduser("~") thefolder="/Randopitons" default_folder=thehome+thefolder -##def dlmap(maptype,choice): -# folderptr=choice-1 -# fullpath=thehome+"/"+foldernames[folderptr] -# try: -# if foldernames[folderptr] == "All": -# for foldernames in totalfolders: -# os.mkdir(os.path.join(thehome,str(foldernames))) -# #subprocess.call("rm -d "+fullpath) -# print "All folders were created successfully" -# else: -# os.mkdir(fullpath) -# print "Folder "+fullpath+"was created successfully" -# -# -# for foldernames in tolimit: -# os.mkdir(os.path.join(thehome,str(foldernames))) -# -# except OSError, e: -# print colrs.WARNING+("Operating System error: {0}".format(e))+colrs.ENDC - - -print "\n\nWelcome ! \nWith this script, you will be able to download gpx,trk and kml traces for hitchiking on the Reunion Isle." -#=================CREATING MAIN FOLDER AND OTHERS OR ALL=================== -try: - chosing_folder=input("\n\nWhich folder would you want to download the files to [Default to home directory "+default_folder+"]") - print "Folder "+chosing_folder+" was created successfully" - #dlmap(maptype,choice) -except OSError, e: - #errors out if folder exists else print the error (can be permissions or anything else) - if e.errno == os.errno.EEXIST: - print colrs.WARNING+("The folder already exists !")+colrs.ENDC - else: - print colrs.FAIL+("Operating System error: {0}".format(e))+colrs.ENDC - pass -except SyntaxError: - print "\nCreating default folder "+default_folder+" ..." +def mkfolder(maptype,choice): + folderptr=choice-1 + fullpath=thehome+"/"+foldernames[folderptr] + try: + if foldernames[folderptr] == "All": + for foldernames in totalfolders: + os.mkdir(os.path.join(thehome,str(foldernames))) + #subprocess.call("rm -d "+fullpath) + print "All folders were created successfully" + else: + os.mkdir(fullpath) + print "Folder "+fullpath+"was created successfully" + + + for foldernames in tolimit: + os.mkdir(os.path.join(thehome,str(foldernames))) + + except OSError, e: + print e.os + print format(e) + +def mainfolder(): + try: + chosing_folder=input("\n\nWhich folder would you want to download the files to [Default to home directory "+default_folder+"]") + print "Folder "+chosing_folder+" was created successfully" + except OSError, e: + #errors out if folder exists else print the error (can be permissions or anything else) + if e.errno == os.errno.EEXIST: + print e.direxist + else: + print e.os + print format(e) + pass + except SyntaxError: + print "\nCreating default folder "+default_folder+" ..." os.mkdir(default_folder) - - - - - - #================DECLARING FOLDERNAMES============== - - - - -print "Program ended." +#print "Program ended." -- cgit v1.2.3-70-g09d2