# #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. Specifies the software version. e.g,, version=4.2.6 Specifies the software install path. Default: /share/apps/soft/autodock Specifies the software env path. Default: /share/apps/envs Specifies the software source path. e.g,, /mnt/usb Default: /mnt/usb install the autodock software. """ 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('--------------------------------------------------------')