我有两个日期字符串(取自用户输入,可能会有很大差异)
s1 = '2011:10:01:10:30:00'
s2 = '2011:10:01:11:15:00'
我希望找到两者之间的差异作为分钟。
我应该如何着手解决这个问题?
我正在尝试获取正在处理的服务器的简称.
我在jinja2中有这个:
ServerAlias graphite.{{ hostvars[inventory_hostname] }}
ServerAlias graphite.{{ hostvars[inventory_hostname] }}.{{dc}}.{{subnet}}
上面只是溢出了整个事实,而不仅仅是短名称.
这就是hosts.yaml的样子:
graphite.experimental.com dc=lv1 subnet=coupons.lan
我有一个带有以下树的烧瓶应用程序:
root/
  - modules/
    __init__.py
    - common/
        __init__.py
    - citrixlb/
        __init__.py # blueprint code
        citrixlb.py # module class
    - aws/
        __init__.py # blueprint code
        aws.py      # module class
所以我想知道,有没有办法动态列出所有蓝图的所有路线?
我有这个root/__init__.py:
# import our modules
from modules.citrixlb import *
from modules.aws import *
app.register_blueprint(aws)
app.register_blueprint(citrix)
如果我可以动态列出所有蓝图的所有路由,我就可以自动生成链接。
例子:
落下: AWS
/aws
/aws/ec2
/aws/subnets
有没有一种方法可以使用一个标签创建名称空间  kubectl?
例如
kubectl create ns <newnamespace> label=appid:foo12
而不是使用kubectl apply -f <somefile>
我希望以这样的方式修改我的代码,使列扩展以容纳数据.
下面是一个断行的示例
+========+=========+===============+=============+=============+
| Record | Cluster | Current Build | Current Use | Environment |
+--------+---------+---------------+-------------+-------------+
| 3      | 1       | v44           | v44 Live (currently - new company cluster)| PROD        |
+--------+---------+---------------+-------------+-------------+
这是我正在使用的(kludgy)代码
sub printData {
   if (@_) {
      # print the data grid top border
      printf ("%10s%10s%15s%14s%14s",'+'.('=' x 8).'+',('=' x 9).'+',('=' x 15).'+',('=' x 13).'+',('=' x 13).'+');
      print "\n";
      # print the data grid column titles
      printf ("%-9s%-10s%-16s%-14s%-15s",'| Record ','| Cluster ','| Current Build ','| Current Use …我有以下输出:
 <forms>
   <form id="15">
      <start>2013-12-09</start>
      <end>2014-01-05</end>
   </form>
</forms>
我想测试一下当前日期是否等于或大于“开始”并且小于或等于“结束”
我将如何进行测试?
我想到的是:
<xsl:variable name="fstart">
   <xsl:value-of select="start" />
</xsl:variable>
<xsl:variable name="fend">
   <xsl:value-of select="end" />
</xsl:variable>
<xsl:choose>
   <xsl:when test="$fstart >= currentdate xor currentdate <= $fend ">
      <!-- do stuff -->
   </xsl:when>
   <xsl:otherwise>
   </xsl:otherwise>
</xsl:choose>
我想将当前日期与开始日期和结束日期进行比较.
XML是:
<forms>
  <form id="11">
     <start>somedate</start>
     <end>someotherdate</end>
   </form>
</forms>
我目前正在尝试:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
xmlns:ex="http://exslt.org/dates-and-times" extension-element-prefixes="ex" >
<xsl:choose>
   <xsl:when test="end != ''                
      and start != '' 
      and ex:date(start) <= current-date() 
      and current-date() <= ex:date(end)">
      <!-- Do Stuff -->
   </xsl:when>
</xsl:choose>
我收到以下错误:
xmlXPathCompOpEval: function current-date not found
XPath error : Unregistered function
XPath error : Stack usage errror
<ul class="ccb_forms_ul"></ul>
从我们自己的repo安装apt软件包时,我在CLI上获得以下内容:
Install these packages without verification? [y/N]
问题是,如何使用ansible成功安装这些软件包?
即使使用force选项,ansible也无法安装包.
我正在使用的命令是:
- apt: name=coupons-graphite dpkg_options='force' state=present
2.2 版
我想获得以下变量的切片,我该怎么做?
hostvars[inventory_hostname]['ansible_hostname']|list
基本上我有一个主机名,hostname001我希望检索最后两个字符。
How do I split it and slice it?
如何在python中压缩文件以及如何指定压缩级别?
到目前为止,我有以下代码,我得到的错误是:
Zip("log4j.dl-service.log.2013-05-03-22",9)
AttributeError: 'str' object has no attribute 'ZipFile'
码:
import zipfile
import fileinput
def Zip(file,level):
    """
    This function uses the zip library native to python to compress files with
    Usage: Zip(file,level)
    """
    if file and level:
        try:
            zipfile = file+'.zip'
            output = zipfile.ZipFile(zipfile, 'wb')
            for line in fileinput.input(file):
                output.write(line)
            output.close()
            if os.path.exists(zipfile):
                return zipfile
            else:
                logMe('critical',"zip failed in Zip()")
                return False
        except Exception,e:
            logMe('critical',e)