質問編集履歴
3
内容修正
test
CHANGED
File without changes
|
test
CHANGED
@@ -1,36 +1,4 @@
|
|
1
|
-
以下のPythonコードがあります。
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
#外部から値を取得
|
8
|
-
|
9
|
-
currentDirectory = configParser.get('Title','CUR_DIR')
|
10
|
-
|
11
|
-
logDirectory = configParser.get('Title','LOG_DIR')
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
UTL_LOG_DIR = LOG_DIR
|
16
|
-
|
17
|
-
UTL_LOG_SUBDIR = LOG_DIR+"/Utility/"+datetime.now().strftime('%Y%m/%m%d')
|
18
|
-
|
19
|
-
UTL_FILE = UTL_LOG_SUBDIR + "/Utility_" + ONE.lstrip('--')+"_"+ NAME + ".log"
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
#If Directory is Nothing,making Directory
|
24
|
-
|
25
|
-
if not os.path.isdir(UTL_LOG_SUBDIR):
|
26
|
-
|
27
|
-
os.makedirs(UTL_LOG_SUBDIR)
|
28
|
-
|
29
|
-
os.chmod(UTL_LOG_SUBDIR,0777)
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
1
|
+
pythonでos.mkdir(dir)をsudo mkdir ...と同じ動きにしたいです。
|
34
2
|
|
35
3
|
環境はEC2上のAmazon Linuxでsu切り替えなしで、cronで動かしています。
|
36
4
|
|
2
変数名変更
test
CHANGED
File without changes
|
test
CHANGED
@@ -6,51 +6,27 @@
|
|
6
6
|
|
7
7
|
#外部から値を取得
|
8
8
|
|
9
|
-
|
9
|
+
currentDirectory = configParser.get('Title','CUR_DIR')
|
10
10
|
|
11
|
-
|
11
|
+
logDirectory = configParser.get('Title','LOG_DIR')
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
#Logging Setting
|
16
|
-
|
17
|
-
RUN_DT = datetime.now()
|
18
12
|
|
19
13
|
|
20
14
|
|
21
|
-
UT
|
15
|
+
UTL_LOG_DIR = LOG_DIR
|
22
16
|
|
23
|
-
UT
|
17
|
+
UTL_LOG_SUBDIR = LOG_DIR+"/Utility/"+datetime.now().strftime('%Y%m/%m%d')
|
24
18
|
|
25
|
-
UTL_
|
19
|
+
UTL_FILE = UTL_LOG_SUBDIR + "/Utility_" + ONE.lstrip('--')+"_"+ NAME + ".log"
|
26
20
|
|
27
21
|
|
28
22
|
|
29
23
|
#If Directory is Nothing,making Directory
|
30
24
|
|
31
|
-
if not os.path.isdir(UT
|
25
|
+
if not os.path.isdir(UTL_LOG_SUBDIR):
|
32
26
|
|
33
|
-
os.makedirs(UT
|
27
|
+
os.makedirs(UTL_LOG_SUBDIR)
|
34
28
|
|
35
|
-
os.chmod(UT
|
29
|
+
os.chmod(UTL_LOG_SUBDIR,0777)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
もしディレクトリがなかったらmkdirコマンドでディレクトリを作成しますが、以下のエラーがでます。
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
Traceback (most recent call last):
|
44
|
-
|
45
|
-
File "./DynamoUtility.py", line 355, in <module>
|
46
|
-
|
47
|
-
os.makedirs(UTIL_LOG_SUBDIR)
|
48
|
-
|
49
|
-
File "/usr/lib64/python2.6/os.py", line 157, in makedirs
|
50
|
-
|
51
|
-
mkdir(name, mode)
|
52
|
-
|
53
|
-
OSError: [Errno 13] Permission denied: '/var/log/taka/DynamoUtility/201606/0610'
|
54
30
|
|
55
31
|
|
56
32
|
|
1
使用環境の追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -56,6 +56,8 @@
|
|
56
56
|
|
57
57
|
これをsudo mkdir ...と同じ動きにしたいです。
|
58
58
|
|
59
|
+
環境はEC2上のAmazon Linuxでsu切り替えなしで、cronで動かしています。
|
60
|
+
|
59
61
|
|
60
62
|
|
61
63
|
よろしくお願いいたします。
|