-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalex-init
executable file
·70 lines (63 loc) · 2.02 KB
/
alex-init
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
#!/usr/local/bin/pebl-language
define Start( par ) {
## This is the folder where we look for support files:
gAlexDir <- "Library/Init/"
## It can itself be in a number of places:
dirs <- [ "", # Current folder takes precedence
"/usr/share/alex/", # Linux
"/usr/local/share/alex/", # OS X
"C:\Program Files\alex\\", # Windows
"C:\Program Files (x86)\alex\\" # Windows (64-bit)
]
## Here we find out where:
found <- 0
loop( gD, dirs ) {
if( IsDirectory( gD + gAlexDir ) ) {
gAlexDir <- gD + gAlexDir
found <- 1
Print( gAlexDir + " found!" )
break
} else {
Print( gD + gAlexDir + " not found, moving on" )
}
}
if( not found ) {
SignalFatalError( "Cannot find "+gAlexDir+" anywhere" )
}
# Experiment name:
gExpDir <- Nth(par, 1)
if( IsDirectory( gExpDir ) ) {
SignalFatalError( "Folder "+gExpDir+" already exists, stopping" )
}
gExpDir <- gExpDir + "/"
Print( "Creating experiment in " + gExpDir )
MakeDirectory( gExpDir )
loop( f, GetDirectoryListing( gAlexDir ) ) {
MakeDirectory( gExpDir + f )
}
loop( f, GetDirectoryListing( gAlexDir + "Design" ) ) {
if( f != "." and f != ".." ) {
source <- gAlexDir + "Design/" + f
destination <- gExpDir + "Design/" + f
AppendFile( destination, source )
}
}
loop( f, GetDirectoryListing( gAlexDir + "Materials" ) ) {
if( f != "." and f != ".." ) {
source <- gAlexDir + "Materials/" + f
destination <- gExpDir + "Materials/" + f
AppendFile( destination, source )
}
}
if( GetSystemType() == "WINDOWS" ) {
runExp <- gExpDir + "/RunExperiment.bat"
alexbat <- gD + "alex.bat"
AppendFile( runExp, alexbat )
} else { # Linux and Mac OS X
file <- FileOpenWrite( gExpDir + "/RunExperiment.sh" )
FilePrint( file, "#!/bin/sh" )
FilePrint( file, "alex" )
FileClose( file )
SystemCall( "chmod u+x "+gExpDir+"/RunExperiment.sh" )
}
}