10
10
PURPOSE. See the above copyright notices for more information.
11
11
=========================================================================*/
12
12
13
+ /**
14
+ * Batchmake_KWBatchmakeComponent
15
+ * provides utility methods needed to interact with Batchmake via Midas3.
16
+ */
13
17
class Batchmake_KWBatchmakeComponent extends AppComponent
14
18
{
15
19
16
- // TODO add function level comments
17
20
18
21
protected $ configPropertiesRequirements = array (TMP_DIR_PROPERTY => CHECK_IF_CHMODABLE_RW ,
19
- BIN_DIR_PROPERTY => CHECK_IF_READABLE ,
20
- SCRIPT_DIR_PROPERTY => CHECK_IF_READABLE ,
21
- APP_DIR_PROPERTY => CHECK_IF_READABLE ,
22
- DATA_DIR_PROPERTY => CHECK_IF_CHMODABLE_RW ,
23
- CONDOR_BIN_DIR_PROPERTY => CHECK_IF_READABLE );
22
+ BIN_DIR_PROPERTY => CHECK_IF_READABLE ,
23
+ SCRIPT_DIR_PROPERTY => CHECK_IF_READABLE ,
24
+ APP_DIR_PROPERTY => CHECK_IF_READABLE ,
25
+ DATA_DIR_PROPERTY => CHECK_IF_CHMODABLE_RW ,
26
+ CONDOR_BIN_DIR_PROPERTY => CHECK_IF_READABLE );
24
27
25
28
protected $ applicationsPaths = array (CONDOR_STATUS => CONDOR_BIN_DIR_PROPERTY ,
26
- CONDOR_QUEUE => CONDOR_BIN_DIR_PROPERTY ,
27
- CONDOR_SUBMIT => CONDOR_BIN_DIR_PROPERTY ,
28
- CONDOR_SUBMIT_DAG => CONDOR_BIN_DIR_PROPERTY ,
29
- BATCHMAKE_EXE => BIN_DIR_PROPERTY );
29
+ CONDOR_QUEUE => CONDOR_BIN_DIR_PROPERTY ,
30
+ CONDOR_SUBMIT => CONDOR_BIN_DIR_PROPERTY ,
31
+ CONDOR_SUBMIT_DAG => CONDOR_BIN_DIR_PROPERTY ,
32
+ BATCHMAKE_EXE => BIN_DIR_PROPERTY );
30
33
31
34
32
35
33
36
34
- public function GetConfigPropertiesRequirements ()
35
- {
36
- return $ this ->configPropertiesRequirements ;
37
- }
37
+ /**
38
+ * @method getConfigPropertiesRequirements()
39
+ * accessor method for set of config properties and their requirements.
40
+ */
41
+ public function getConfigPropertiesRequirements ()
42
+ {
43
+ return $ this ->configPropertiesRequirements ;
44
+ }
38
45
39
- public function GetApplicationsPaths ()
40
- {
41
- return $ this ->applicationsPaths ;
42
- }
46
+ /**
47
+ * @method getApplicationsPaths()
48
+ * accessor method for set of application paths needed by batchmake module.
49
+ */
50
+ public function getApplicationsPaths ()
51
+ {
52
+ return $ this ->applicationsPaths ;
53
+ }
43
54
44
55
45
56
/**
46
- * @method LoadApplicationConfig ()
57
+ * @method loadApplicationConfig ()
47
58
* written in the hope of being reusable
48
59
*/
49
- function LoadApplicationConfig ()
60
+ function loadApplicationConfig ()
50
61
{
51
62
if (file_exists (BATCHMAKE_MODULE_LOCAL_CONFIG ))
52
63
{
@@ -62,80 +73,100 @@ function LoadApplicationConfig()
62
73
63
74
64
75
65
- public function CheckFileFlag ($ file , $ options = 0x0 )
76
+ /**
77
+ * @method checkFileFlag()
78
+ * checks whether the file at the passed in path has the passed in options.
79
+ */
80
+ public function checkFileFlag ($ file , $ options = 0x0 )
66
81
{
67
82
$ exist = file_exists ($ file );
68
- Zend_Loader::loadClass ("InternationalizationComponent " ,BASE_PATH .'/core/controllers/components ' );
83
+ Zend_Loader::loadClass ("InternationalizationComponent " , BASE_PATH .'/core/controllers/components ' );
69
84
$ status = ($ exist ? InternationalizationComponent::translate (EXIST_STRING ) : InternationalizationComponent::translate (NOT_FOUND_ON_CURRENT_SYSTEM_STRING ));
70
85
$ ret = $ exist ;
71
86
72
- if ( $ exist && ($ options & CHECK_IF_READABLE ) )
87
+ if ( $ exist && ($ options & CHECK_IF_READABLE ))
73
88
{
74
89
$ readable = is_readable ($ file );
75
- $ status .= $ readable ? " / Readable " : " / NotReadable " ;
90
+ $ status .= $ readable ? " / Readable " : " / NotReadable " ;
76
91
$ ret = $ ret && $ readable ;
77
92
}
78
93
79
- if ( $ exist && ($ options & CHECK_IF_WRITABLE ) )
94
+ if ( $ exist && ($ options & CHECK_IF_WRITABLE ))
80
95
{
81
96
$ writable = is_writable ($ file );
82
- $ status .= $ writable ? " / Writable " : " / NotWritable " ;
97
+ $ status .= $ writable ? " / Writable " : " / NotWritable " ;
83
98
$ ret = $ ret && $ writable ;
84
99
}
85
- if ( $ exist && ($ options & CHECK_IF_EXECUTABLE ) )
100
+ if ( $ exist && ($ options & CHECK_IF_EXECUTABLE ))
86
101
{
87
102
$ executable = is_executable ($ file );
88
- $ status .= $ executable ? " / Executable " : " / NotExecutable " ;
103
+ $ status .= $ executable ? " / Executable " : " / NotExecutable " ;
89
104
$ ret = $ ret && $ executable ;
90
105
}
91
- if ( !$ this ->IsWindows () && $ exist && ($ options & CHECK_IF_CHMODABLE ) )
106
+ if ( !$ this ->IsWindows () && $ exist && ($ options & CHECK_IF_CHMODABLE ))
92
107
{
93
108
$ chmodable = $ this ->IsChmodable ($ file );
94
- $ status .= $ chmodable ? " / Chmodable " : " / NotChmodable " ;
109
+ $ status .= $ chmodable ? " / Chmodable " : " / NotChmodable " ;
95
110
$ ret = $ ret && $ chmodable ;
96
111
}
97
112
return array ($ ret , $ status );
98
113
}
99
114
100
115
101
- // STUFF FROM KWUTILS, where should it go?
102
116
103
- /** Return True if the current platform is windows */
104
- function IsWindows ()
117
+ /**
118
+ * @method isWindows()
119
+ * from KWUtils, may need to be moved.
120
+ * @return True if the current platform is windows
121
+ */
122
+ function isWindows ()
105
123
{
106
- return (strtolower ( substr (PHP_OS ,0 , 3 ) ) == "win " );
124
+ return (strtolower (substr (PHP_OS , 0 , 3 ) ) == "win " );
107
125
}
108
126
109
- /** Return True if the current platform is linux */
110
- function IsLinux ()
127
+ /**
128
+ * @method isLinux()
129
+ * from KWUtils, may need to be moved.
130
+ * @return True if the current platform is Linux
131
+ */
132
+ function isLinux ()
111
133
{
112
- return (strtolower ( substr (PHP_OS ,0 , 5 ) ) == "linux " );
134
+ return (strtolower (substr (PHP_OS , 0 , 5 ) ) == "linux " );
113
135
}
114
136
115
- /** Format the application name according to the plateform */
116
- function FormatAppName ( $ app_name )
137
+ /**
138
+ * @method formatAppName
139
+ * from KWUtils, may need to be moved.
140
+ * Format the application name according to the platform.
141
+ */
142
+ function formatAppName ($ app_name )
117
143
{
118
- if (substr (PHP_OS ,0 , 3 ) == "WIN " )
144
+ if (substr (PHP_OS , 0 , 3 ) == "WIN " )
119
145
{
120
- $ app_name = self ::AppendStringIfNot ($ app_name ,".exe " );
146
+ $ app_name = self ::AppendStringIfNot ($ app_name , ".exe " );
121
147
}
122
148
return $ app_name ;
123
149
}
124
150
125
151
/**
152
+ * @method isChmodable
126
153
* Check if current PHP process has permission to change the mode
127
154
* of $fileOrDirectory.
155
+ * from KWUtils, may need to be moved.
128
156
* Note: If return true, the mode of the file will be DEFAULT_MKDIR_MODE
129
157
* On windows, return always True
130
158
*/
131
- function IsChmodable ( $ fileOrDirectory )
159
+ function isChmodable ( $ fileOrDirectory )
132
160
{
133
- if ($ this ->IsWindows ()) { return true ; }
161
+ if ($ this ->isWindows ())
162
+ {
163
+ return true ;
164
+ }
134
165
135
- if ( !file_exists ($ fileOrDirectory ) )
166
+ if ( !file_exists ($ fileOrDirectory ))
136
167
{
137
- Zend_Loader::loadClass ("InternationalizationComponent " ,BASE_PATH .'/core/controllers/components ' );
138
- self ::Error (InternationalizationComponent::translate (FILE_OR_DIRECTORY_DOESNT_EXIST_STRING )." [ $ fileOrDirectory] " );
168
+ Zend_Loader::loadClass ("InternationalizationComponent " , BASE_PATH .'/core/controllers/components ' );
169
+ self ::Error (InternationalizationComponent::translate (FILE_OR_DIRECTORY_DOESNT_EXIST_STRING ).' [ ' . $ fileOrDirectory. ' ] ' );
139
170
return false ;
140
171
}
141
172
@@ -144,10 +175,13 @@ function IsChmodable( $fileOrDirectory)
144
175
//$current_perms = self::GetFilePermissions( $fileOrDirectory );
145
176
$ current_perms = DEFAULT_MKDIR_MODE ;
146
177
//self::Debug("File permissions: [file: $fileOrDirectory, mode: ".decoct($current_perms)."]");
147
- if ($ current_perms ===false ){ return false ; }
178
+ if ($ current_perms === false )
179
+ {
180
+ return false ;
181
+ }
148
182
149
183
// Try to re-apply them
150
- if (!@chmod ($ fileOrDirectory , $ current_perms ))
184
+ if (!@chmod ($ fileOrDirectory , $ current_perms ))
151
185
{
152
186
//self::Debug("Failed to change mode: [file: $fileOrDirectory] to [mode: ".decoct($current_perms)."]");
153
187
return false ;
0 commit comments