我试图将我的变量传递raw_input给我的子进程命令.我是Python的新手.任何帮助他都会赞赏.
#!/usr/bin/python
import subprocess
print "\nWhat user name"
username = str(raw_input('username: '))
print "\nWhat is the user id"
userid = int(raw_input('Enter user id: '))
print "\nWhat is the user\'s primary group?"
primarygroup = int(raw_input('Enter group: '))
print "\nWhat is the user\'s secondary group?"
secondarygroup = int(raw_input('Enter group: '))
subprocess.call(['useradd' '-m' '-g' _primarygroup '-G' _secondarygroup '-u' _userid _username])
print"\nThe user has been added"
Run Code Online (Sandbox Code Playgroud) 我们最近在我们的服务器上重新组织了一个非常无组织的站点.该网站使用Mercurial进行版本控制.我们重新组织了一切.成千上万的文件.现在,当我这样做时,hg status它显示了大量新的未跟踪文件,由?大量丢失的文件表示,这些文件与未跟踪的文件相同,由a表示!.
我如何告诉Mercurial我们移动了这些文件?我知道我可以一个接一个地做,但鉴于有数以千计,这不是一个选择.
如果一个分支有两个头怎么办?几个星期前我出现了这种情况,因为某些原因我当时没有将它们合并,只是继续在一个头上开发.现在我想摆脱另一个头.我该怎么办?我应该在这么多变更后合并它们吗?
我是python和编码的新手.我试图从一个文本文件中读取每行都有路径名.我想逐行读取文本文件,并将行字符串拆分为驱动器,路径和文件名.
这是我到目前为止的代码:
import os,sys, arcpy
## Open the file with read only permit
f = open('C:/Users/visc/scratch/scratch_child/test.txt')
for line in f:
(drive,path,file) = os.path.split(line)
print line.strip()
#arcpy.AddMessage (line.strip())
print('Drive is %s Path is %s and file is %s' % (drive, path, file))
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
File "C:/Users/visc/scratch/simple.py", line 14, in <module>
(drive,path,file) = os.path.split(line)
ValueError: need more than 2 values to unpack
Run Code Online (Sandbox Code Playgroud)
当我只想要路径和文件名时,我没有收到此错误.
我想用BottlePy返回一个html模板.这很好用.但是如果我在我的tpl文件中插入这样的javascript文件:
<script type="text/javascript" src="js/main.js" charset="utf-8"></script>
Run Code Online (Sandbox Code Playgroud)
我收到404错误. (无法加载资源:服务器响应状态为404(未找到))
有谁知道如何解决这个问题?
这是我的脚本文件:
from bottle import route, run, view
@route('/')
@view('index')
def index():
return dict()
run(host='localhost', port=8080)
Run Code Online (Sandbox Code Playgroud)
这是模板文件,位于"./views"子文件夹中.
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="js/main.js" charset="utf-8"></script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
也许它是从开发服务器查找我的js文件的"rootPath/js/main.js"?
文件的结构是:
app.py
-js
main.js
-views
index.tpl
Run Code Online (Sandbox Code Playgroud)
谢谢.
我正在制作Flask应用程序.我有一个登录区,一个博客区.如果我想获得用户的登录,我将呈现登录模板.但这不会使博客模板必须显示在登录区域下方.:/
我会尽量让它更清楚:
{% block login %} {% endblock %}
blah blah
{% block blog_display %} {% endblock %}
Run Code Online (Sandbox Code Playgroud)
现在我有一个login.html扩展它,并进入登录块.我有一个blogs.html进入blog_display.如何渲染两者?当我这样做render_template(),我可以把它叫做只的一个login.html或blogs.html.
请帮帮我.如果你要求,我会提供更多细节.
在生产服务器上,当ASP .NET应用程序崩溃时,我可以从系统事件查看器中看到此事件:
EventType clr20r3,P1 w3wp.exe,P2 6.0.3790.3959,P3 45d691cc,
P4 app_web_default.aspx.cdcab7d2,P5 0.0.0.0,P6 4b2e4bf0,P7 4,P8 4,P9
system.dividebyzeroexception,P10 NIL.*
它属于".NET Runtime 2.0错误报告"类别.
但我找不到属于"ASP.NET 2.0.50727.0"类别的事件,它可以给我这个例外这样的详细视图:
An unhandled exception occurred and the process was terminated.
Application ID: /LM/W3SVC/505951206/Root
Process ID: 1112
Exception: System.DivideByZeroException
Message: Attempted to divide by zero.
StackTrace:
at _Default.Foo(Object state)
at System.Threading.ExecutionContext.runTryCode(Object userData)
at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)
For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp …Run Code Online (Sandbox Code Playgroud) 我更喜欢在.hgignore文件中使用glob语法,但现在我需要创建一个root模式.我想忽略我的/ static目录,但不是/ assets/static.这条线
static/
Run Code Online (Sandbox Code Playgroud)
忽略了两者.有没有办法做root的glob模式?如果没有,我可以切换到正则表达式,但是对于匹配路径名,glob似乎更自然.
假设我有这个:
hg clone public_repo my_repo
touch a b c d
hg add .
hg commit -m a a
hg commit -m b b
hg commit -m c c
hg commit -m d d
hg push
# let's say revX is the revision that added a
hg strip revX
Run Code Online (Sandbox Code Playgroud)
在我的存储库的历史记录中,提交已经消失.但是,如果我尝试在条带之后进行推动,它会告诉我no changes found.这条带可以应用于公共仓库吗?
编辑:问题只是假设:).我不是在这种情况下,我只是觉得找出它如何工作会很有趣.
我hg archive前一段时间给了别人一份我的代码.从那以后发生了很多提交,我不记得我给他的修改是哪一个.有一些关于我在.hg_archival.txt文件中给予该人的版本的信息.例如,它具有节点哈希信息node: 72f497079285b2c3cf4f8b86950664f84221cd63
使用.hg_archival.txt文件中的信息(如节点哈希)如何在TortoiseHg中显示的修订图中找到相应的修订节点?