text
stringlengths 0
828
|
|---|
""""""
|
Add a t_hosts record
|
:param f_ipaddr: IP address
|
:param f_macaddr: MAC Address
|
:param f_hostname: Hostname
|
:param f_netbios_name: NetBIOS Name
|
:param f_engineer: Engineer username
|
:param f_asset_group: Asset group
|
:param f_confirmed: Confirmed boolean
|
:return: (True/False, t_hosts.id or response message)
|
""""""
|
return self.send.host_add(f_ipaddr, f_macaddr, f_hostname, f_netbios_name, f_engineer,
|
f_asset_group, f_confirmed)"
|
721,"def parse_now_field(s):
|
""""""Return a datetime instance from a string generated by now_field.
|
IMPORTANT: the datetime will be in UTC""""""
|
if not s.startswith('UTC:'):
|
return None # Invalid string
|
s = s[4:]
|
# isoformat can return strings both with and without microseconds - we
|
# account for both
|
try:
|
dt = datetime.datetime.strptime(s, '%Y-%m-%dT%H:%M:%S.%f')
|
except ValueError:
|
dt = datetime.datetime.strptime(s, '%Y-%m-%dT%H:%M:%S')
|
return dt"
|
722,"def get_ftp(ftp_conf, debug=0):
|
""""""得到一个 已经打开的FTP 实例,和一个 ftp 路径。
|
:param dict ftp_conf: ftp配置文件,格式如下:
|
>>> {
|
>>> 'server':'127.0.0.1',
|
>>> 'start_path':None,
|
>>> 'user':'admin',
|
>>> 'password':'123456',
|
>>> }
|
:returns: ftp, ftpserverstr
|
:rtype: :class:`ftplib.FTP` , str
|
""""""
|
server = ftp_conf.get('server')
|
user = ftp_conf.get('user')
|
password = ftp_conf.get('password')
|
start_path = ftp_conf.get('start_path')
|
slog.info(""Connecting FTP server %s ......"", server)
|
ftpStr = 'ftp://%s/'%server
|
if start_path:
|
ftpStr = ftpStr+start_path
|
ftp = ftplib.FTP(server, user, password)
|
ftp.set_debuglevel(debug)
|
if start_path:
|
ftp.cwd(start_path)
|
serverFiles = ftp.nlst()
|
slog.info('There are some files in %s:\n[%s]'%(ftpStr, ', '.join(serverFiles)))
|
return ftp, ftpStr"
|
723,"def upload_file(file_path, remote_path, ftp_conf, remove_file=False):
|
""""""上传第一个指定的文件到 FTP 服务器。
|
:param str file_path: 待上传文件的绝对路径。
|
:param str remote_path: 文件在 FTP 服务器上的相对路径(相对于 FTP 服务器的初始路径)。
|
:param dict ftp_conf: ftp配置文件,详见 :func:`get_ftp` 。
|
:param bool remove_file: 上传成功后是否删除本地文件。
|
:returns: FTP 服务器上的文件列表
|
:rtype: list
|
""""""
|
check_ftp_conf(ftp_conf)
|
ftp, ftpStr = get_ftp(ftp_conf)
|
lf = open(file_path, 'rb')
|
slog.info('Uploading ""%s"" to ""%s/%s"" ......'%(file_path, ftpStr, remote_path))
|
ftp.storbinary(""STOR %s""%remote_path, lf)
|
filelist = ftp.nlst()
|
ftp.quit()
|
lf.close()
|
if remove_file:
|
os.remove(file_path)
|
slog.info('Upload done.')
|
return filelist"
|
724,"def retrieve_data(self):
|
""""""
|
Retrives data as a DataFrame.
|
""""""
|
#==== Retrieve data ====#
|
df = self.manager.get_historic_data(self.start.date(), self.end.date())
|
df.replace(0, np.nan, inplace=True)
|
return df"
|
725,"def get_min_risk(self, weights, cov_matrix):
|
""""""
|
Minimizes the variance of a portfolio.
|
""""""
|
def func(weights):
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.