我用了创建了一个脚本argparse.
脚本需要将配置文件名作为选项,用户可以指定是否需要完全继续脚本或仅模拟脚本.
要通过的args:./script -f config_file -s或./script -f config_file.
对于-f config_file部分是可以的,但是它一直在问我-s的参数是哪个是选项,不应该是任何参数.
我试过这个:
parser = argparse.ArgumentParser()
parser.add_argument('-f', '--file')
#parser.add_argument('-s', '--simulate', nargs = '0')
args = parser.parse_args()
if args.file:
config_file = args.file
if args.set_in_prod:
simulate = True
else:
pass
Run Code Online (Sandbox Code Playgroud)
出现以下错误:
File "/usr/local/lib/python2.6/dist-packages/argparse.py", line 2169, in _get_nargs_pattern
nargs_pattern = '(-*%s-*)' % '-*'.join('A' * nargs)
TypeError: can't multiply sequence by non-int of type 'str'
Run Code Online (Sandbox Code Playgroud)
与错误相同''而不是0.
我正在寻找一种在我自己的服务器上托管私人git repos的方法.
我正在使用Github作为我的开源项目,但我更喜欢使用自己的服务器来存储私有git存储库.
有人可以建议我应该使用哪个脚本来实现此目的.
但Trac不是我想要的.我想要的东西,最好是基于PHP的解决方案(只是可选的)和esp.具有更简单UI的东西.
这里有任何帮助.
我正在寻找生成成功/失败消息,这些消息在bash中是正确的.一个例子是apache2在执行时产生的内容:sudo /etc/init.d/apache2 reload等等
在上面的例子中,apache2产生非常好的和简洁的[OK]或者[fail]右对齐的消息.
此外,我们很想知道如何让文字变红,以防万一我们要发[fail]短信.
我正在使用编码的PHP脚本,它需要对CURL的SSL支持.
我目前正在使用XAMPP进行本地开发,并且需要知道如何更新默认CURL,以便通过它启用SSL.
我正在寻找升级/支持的原因是我收到以下错误,当谷歌搜索等等.我明白我的机器上的CURL不支持SSL.
SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Run Code Online (Sandbox Code Playgroud)
有人对我有任何建议吗?我当前的本地服务器配置:
XAMPP 1.7.3 cURL支持 启用
cURL信息 7.19.6
Apache版本 Apache/2.2.14(Win32)DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4的Perl/v5.10.1
加载模块 芯mod_win32 mpm_winnt http_core mod_so mod_actions mod_alias中mod_asis mod_auth_basic mod_auth_digest的mod_authn_default mod_authn_file模块mod_authz_default mod_authz_groupfile mod_authz_host mod_authz_user mod_cgi一样的mod_dav mod_dav_fs可以mod_dav_lock的mod_dir mod_env mod_headers中mod_include负责mod_info mod_isapi mod_log_config mod_mime mod_negotiation模块的mod_rewrite mod_setenvif mod_ssl的mod_status的mod_vhost_alias mod_autoindex_color mod_php5的mod_perl mod_apreq2
SERVER_SIGNATURE Apache/2.2.14(Win32)DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1服务器在localhost端口80
SERVER_SOFTWARE Apache/2.2.14(Win32)DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1
这个问题是关于在Mac OS X上使用MacVim和ZSH.
我正在使用ZSH shell并且它被配置为使用Colored提示,并且一切都与ZSH本身很好地协作.
但是,当我将此shell设置为Vim(usin :)的默认值时set shell=zsh\ -li,vim在输入或输出文本时会给出以下符号:
[35mnikhgupta[00m at [[33mMacbookPro[00m in [01;32m~[00m [00m
Run Code Online (Sandbox Code Playgroud)
虽然它应该简单地说:
nikhgupta at MacbookPro in ~
Run Code Online (Sandbox Code Playgroud)
当我输入一些文本时,我会得到相同的奇怪符号,可能是因为我正在使用为我的ZSH shell突出显示的语法.我推断这些符号是颜色代码?
有人可以帮我解决如何丢弃这些颜色代码并简单地在Vim shell中输出文本的问题吗?
问候
我的设置可能有问题:
irb(main):001:0> truncate("Once upon a time in a world far far away", :length => 17)
NoMethodError: undefined method `truncate' for main:Object
from (irb):1
from /usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:47:in `start'
from /usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands/console.rb:8:in `start'
from /usr/lib64/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:41:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'
Run Code Online (Sandbox Code Playgroud)
看起来我不能使用任何文本助手(在irb和rails控制台中).
我该怎么检查?
好的,这是一个真正的简短查询。__FILE__我从函数内部调用。现在,这个函数本身位于所需的文件中。
现在,当我从父文件内部调用此函数时,输出是__FILE__父文件还是包含的文件?
哦,如果可能的话,我正在寻找可以确认的来源,因为我在这里的测试给出了完全荒谬的结果。
另外,如果这应该显示子(包含)文件,我应该如何处理才能显示父文件路径?(一些变化或者什么?)
我有一个Emacs组织模式表,如下所示:
|--------------------------------+------------------------------------------------------|
| <20> | <60> |
| How do you alter your password | The command to alter your password in oracle is:: |
| in Oracle? | |
| | ALTER USER {userid} IDENTIFIED BY {password}; |
| | |
|--------------------------------+------------------------------------------------------|
Run Code Online (Sandbox Code Playgroud)
当C-c C-c使用键盘快捷键调整表格大小时:Ctrl-C + Ctrl-C或者自动调整表格元素内部的间距,我得到:
|--------------------------------+------------------------------------------------------|
| <20> | <60> |
| How do you alter your password | The command to alter your password in oracle is:: |
| in Oracle? | | …Run Code Online (Sandbox Code Playgroud) 我正在使用这个javascript在焦点时清空输入/ textarea.
$(document).ready(function() {
$('input[type="text"],textarea').not('[readonly="readonly"]').addClass("idleField");
$('input[type="text"],textarea').focus(function() {
$(this).removeClass("idleField").addClass("focusField");
if (this.value == this.defaultValue){
this.value = '';
}
if(this.value != this.defaultValue){
this.select();
}
});
$('input[type="text"],textarea').blur(function() {
$(this).removeClass("focusField").addClass("idleField");
if ($.trim(this.value) == ''){
this.value = (this.defaultValue ? this.defaultValue : '');
}
});
});
Run Code Online (Sandbox Code Playgroud)
我正在寻找一种方法来排除那些通过input设置的字段.我知道我应该使用(我猜),但我无法弄清楚如何.readonlyreadonly="readonly".not
我有一个脚本,它接受了几个参数.
现在,我已将脚本修改为除多个文件名以外的操作.
我还希望在通过管道(|)或重定向输入(<)接收输入时执行此脚本.但是,当不提供上述三个输入时,我不希望脚本在终端上等待输入,而是显示使用说明.
我使用以下功能:
# PIPED CONTENT
if [ "$#" == "0" ]; then
READINPUT="1"
if [ "x$TEXTINPUT" == x"" ]; then
READINPUT=1
TMPFL=`tempfile -m 777`
while read data; do
echo "${data}" >> $TMPFL
done
TEXTINPUT="`cat $TMPFL`"
rm $TMPFL
fi
# if [ "x$TEXTINPUT" == x"" ]; then
# if [ "$#" == "0" ]; then usage; fi
# fi
fi
Run Code Online (Sandbox Code Playgroud)
任何帮助表示赞赏.
关于
Nikhil Gupta