aboutsummaryrefslogtreecommitdiff
path: root/prototyping/foldercreating.py
blob: 489d5884ab5972fc21118aba4c3b5a309a6d81c2 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import subprocess
import os
import time
import colorcode as clc
import errmsg as e
import randoweb as rdo
#global foldernames

thehome=os.path.expanduser("~")
defoldername="/Randopitons"
def_folder=thehome+defoldername
a_folder=0




def defolder():
    try:
        print "\nCreating default folder "+def_folder+" ..."
        os.mkdir(def_folder)
    except OSError,er:
        print e.os
        print format(er)
        
def mainfolder():
    try:
        a_folder=input("\n\nWhich folder would you want to download the files to [Default to home directory "+def_folder+"]")
        os.mkdir(a_folder)
        print "Folder "+a_folder+" was created successfully"
    except OSError, er:
        #errors out if folder exists else print the error (can be permissions or anything else)
        if e.errno != os.errno.EEXIST:
            raise
        else:
            print e.os
            print format(er)
            pass
        
    except SyntaxError:
        os.mkdir(def_folder)
    except KeyboardInterrupt:
        print e.sigkill
    except:
        raise

def mkfolder(MAIL,PSW,regionnames,foldernames,maptype,ptr,bfn):
    
    try:
        if a_folder==0:
            os.mkdir(os.path.join(def_folder,foldernames[ptr]))
        else:
            os.mkdir(os.path.join(a_folder,foldernames[ptr]))
        #rdo.testalakon()
        rdo.randoweb(MAIL,PSW,regionnames[ptr],maptype,bfn,def_folder+a_str)
    except OSError, er:
        print e.os
        print format(er)
        
        
def mkallfolder(MAIL,PSW,regionnames,foldernames,maptype,bfn):
    iii=0
    a_str="str"
    try:
        for a_str in foldernames:
            if a_folder==0:
                os.mkdir(os.path.join(def_folder,a_str))
            else:
                os.mkdir(os.path.join(a_folder,a_str))
                
                
            try:
                print "on attaque par le "+regionnames[iii]
                rdo.randoweb(MAIL,PSW,regionnames[iii],maptype,bfn,def_folder+a_str)
            except:
                raise
            iii=iii+1
            #subprocess.call("rm -d "+fullpath)
        print "All folders were created successfully"
    except OSError, er:
        print e.os
        print format(er)