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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
#
#coding:utf-8
#
#Author : QCSun
#Email : qcsun@sunhpc.com
#Times : 2023-04-14 05:21:02
#WebSite : https://www.sunhpc.com
import os
import sys
import sunhpc
import shutil
class command(sunhpc.commands.soft.command):
pass
class Command(command):
"""
Build the AutoDock software.
<arg type="string" name="version">
Specifies the software version. e.g,, version=4.2.6
</arg>
<param type="path" name="prefix">
Specifies the software install path.
Default: /share/apps/soft/autodock
</param>
<param type="path" name="envs">
Specifies the software env path.
Default: /share/apps/envs
</param>
<param type="path" name="source">
Specifies the software source path. e.g,, /mnt/usb
Default: /mnt/usb
</param>
<example cmd='soft autodock prefix=/share/apps/soft version=4.2.6'>
install the autodock software.
</example>
"""
def run(self, params, args):
(prefix, version, source, envs) = self.fillParams([
('prefix', '/share/apps/soft/autodock'),
('version', None),
('source', '/mnt/usb'),
('envs', '/share/apps/envs'),
])
if len(args):
version = args[0]
if not version:
self.msg('must supply an "AutoDock version" e.g,, version=4.2.6', 'a')
try:
os.makedirs(prefix)
self.msg("The %s directory does not exist,and it will be created." % prefix, 'w')
except FileExistsError:
pass
if not os.path.exists(envs):
os.makedirs(envs)
if version == '4.2.6':
basename = 'autodock-4.2.6'
else:
self.msg('Version error, Try use version number "4.2.6"', 'a')
filename = '%s.tar.bz2' % basename
softname = os.path.join(source, 'hpcsoft/AutoDock', filename)
if not os.path.exists(softname):
self.msg('The "%s" not found.' % softname, 'a')
destname = os.path.join(prefix, basename)
softlist = os.listdir(prefix)
if basename in softlist:
self.msg('The %s already exists,to reinstall it, remove it first.' % basename, 'w')
else:
self.msg('Start installing the %s software to the %s directory...' % (basename, prefix))
os.system('tar -xf %s -C %s' % (softname, prefix))
gsenv = os.path.join(envs, '%s-env.sh' % basename)
with open(gsenv, 'w') as f:
f.write('#!/bin/sh\n')
f.write('#\n# %s env config\n#\n\n' % basename)
f.write('export PATH=%s/%s:$PATH\n' % (prefix, basename))
# create shared user and group.
self.msg('')
self.msg('--------------------------------------------------------')
self.msg('Create a shared group to run the %s software.' % basename)
self.msg(' 1, groupadd -g 888 public ')
self.msg(' 2, usermod -G public dell ')
self.msg(' 3, chown -R root:public %s/%s' % (prefix, basename))
self.msg('--------------------------------------------------------')
self.msg('')
self.msg(' source %s' % gsenv)
self.msg('--------------------------------------------------------')
|