aboutsummaryrefslogtreecommitdiff
path: root/foldercreating.py
blob: c1f4b236a3634c609a5fbef8237285add18c1c79 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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 lors de la récupération sur site web
thehome=os.path.expanduser("~")
defoldername="/Randopitons"
def_folder=thehome+defoldername
fullpath=thehome+"/"+foldernames[regionptr]

def mainfolder():
    try:
        a_folder=input("\n\nWhich folder would you want to download the files to [Default to home directory "+def_folder+"]")
        print "Folder "+a_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 "+def_folder+" ..."
        os.mkdir(def_folder)

def mkfolder(choice):
    regionptr=choice-1
    try:
        os.mkdir(os.path.join(thehome,foldernames[regionptr]))    
    except OSError, e:
        print e.os
        print format(e)
        
        
def mkallfolder(choice):
    try:
        if choice == 10:
            for foldernames in range(9):
                os.mkdir(os.path.join(thehome,str(foldernames)))
                #subprocess.call("rm -d "+fullpath)
            print "All folders were created successfully"
    except OSError, e:
        print e.os
        print format(e)


#print "Program ended."