小编Leo*_*onH的帖子

在while循环中读取bash中的输入

我有一个bash脚本,如下所示,

cat filename | while read line
do
    read input;
    echo $input;
done
Run Code Online (Sandbox Code Playgroud)

但这显然没有给我正确的输出,因为当我在while循环中读取它时,它试图从文件文件名读取,因为可能的I/O重定向.

还有其他方法吗?

bash while-loop

93
推荐指数
2
解决办法
10万
查看次数

如何在Java中编辑来自另一个类的数组

我创建了一个2d数组(用作游戏板),在另一个类中我想获取我的数组并能够对其执行操作.

我的数组定义(在课堂上PlayingBoard):

public char[][] myGrid = new char[12][12];
Run Code Online (Sandbox Code Playgroud)

现在我想从我项目中的其他类操作这个数组.我试着打电话给该网格中它的类没有定义

int i, j;
for(i = 0; i < 12; i++) {
    for(j = 0; j < 12; j++) {
        PlayingBoard.myGrid[i][j] = 'x';
    }
}
Run Code Online (Sandbox Code Playgroud)

我收到错误:

myGrid无法从静态上下文引用非静态变量

如何myGrid从第二堂课中参考,编辑和操作?

java arrays static

8
推荐指数
1
解决办法
1994
查看次数

event EventHandler vs EventHandler

在C#中使用是否存在根本区别

event EventHandler<myeventargs>并且 EventHandler<myeventargs> 除了使用event关键字之外我们可以看到它们产生相同的效果在intellisense中给你一个不同的图标.

c# event-handling

6
推荐指数
1
解决办法
1214
查看次数

Gmail api线程列表代码段

我一直在尝试使用GMail API和客户端库.我可以使用javascript节点SDK来获取线程列表,但代码片段会以""形式返回.

client.gmail.users.threads.list({userId: "me"}).withAuthClient(auth_with_access_token).execute(function (err, response) {
            res.json({complete: response.threads})
        });
Run Code Online (Sandbox Code Playgroud)

然后我下载了python SDK,并使用gmail api示例获得了一个线程列表,并注意到它们也有空片段.

for thread in threads['threads']:
    print 'Thread: %s' % (thread)
Run Code Online (Sandbox Code Playgroud)

主题ID:{u'snippet':你','你':u'146fccb21d960498',u'historyId':u'7177452'}

当我通过get thread方法请求线程时,我确实得到了一个片段,但是它只在线程列表中丢失了.

我需要在获取代码段的请求中包含其他详细信息吗?

谢谢!

python gmail-api

5
推荐指数
1
解决办法
1268
查看次数

如何在buildbot的shell命令行中添加“ &amp;&amp;”?

我需要使用“ &&”一步执行多个命令。所以我创建工厂如下:

f1 = factory.BuildFactory()
f1.addStep(shell.ShellCommand, command=["sh", "-c", "pwd", "&&", "cd", "/home/xxx/yyy", "&&", "pwd"])
Run Code Online (Sandbox Code Playgroud)

但是在执行过程中,发现buildbot对其进行了如下处理,这使得无法执行

sh -c pwd '&&' cd /home/xxx/yyy '&&' pwd
Run Code Online (Sandbox Code Playgroud)

我所期望的是

sh -c pwd && cd /home/xxx/yyy && pwd
Run Code Online (Sandbox Code Playgroud)

有人可以帮我吗?谢谢。

shell command-line buildbot

5
推荐指数
1
解决办法
893
查看次数

没有足够的权限通过Gmail API删除邮件

我的代码应该在我的收件箱中收到一条消息,检查它是否有链接,然后从电子邮件中提取链接然后将其删除.

message = gmail_service.users().messages().get(userId='me', id=thread['id'], format='raw').execute()    #get message using thread id
msg_str = base64.urlsafe_b64decode(message['raw'].encode('ASCII'))
msg = email.message_from_string(msg_str)
for part in msg.walk():
    msg.get_payload()
    if part.get_content_type() == 'text/html':
        mytext = base64.urlsafe_b64decode(part.get_payload().encode('UTF-8'))
        html = BeautifulSoup(mytext)
        for link in html.find_all('a'):
            mylink = link.get('href')
            print mylink
            try:
                service.users().messages().trash(userId='me', id=thread['id']).execute()
                print 'Message with id: %s trashed successfully.' % msg_id
            except errors.HttpError, error:
                print 'Could not trash ' + thread['id'] + ': %s' % error
Run Code Online (Sandbox Code Playgroud)

我在代码中定义的范围是.modify应该给我,我需要垃圾邮件的权限,没有失败.为什么我收到错误:

<HttpError 403 when requesting https://www.googleapis.com/gmail/v1/users/me/messages/147d8c9a6348e437/trash?alt=json returned "Insufficient …
Run Code Online (Sandbox Code Playgroud)

python debugging google-oauth gmail-api

4
推荐指数
1
解决办法
2265
查看次数

run_flow()的哪个标志将模拟现在已弃用的run()

我正在尝试验证我的凭据以访问GMail API.以前我使用run()OAuth2中的方法和代码执行credentials = tools.run(flow, STORAGE, http=http)此操作,但现在这是一个不推荐使用的方法.我现在正在使用该run_flow()方法来验证我的凭据.

import httplib2
import argparse
from apiclient import errors
from apiclient.discovery import build
from oauth2client import tools
from oauth2client.file import Storage
from oauth2client.client import flow_from_clientsecrets

CLIENT_SECRET_FILE = 'your_client_secret.json'
OAUTH_SCOPE = 'https://www.googleapis.com/auth/gmail.modify'
STORAGE = Storage('gmail.storage')
flow = flow_from_clientsecrets(CLIENT_SECRET_FILE, scope=OAUTH_SCOPE)
http = httplib2.Http()
credentials = STORAGE.get()there are credentials, no reauth is needed
#parser = argparse.ArgumentParser(parents=[tools.argparser])
#flags = parser.parse_args()    #Put your arguments in the parenthesis
if credentials is None or credentials.access_token_expired:
    credentials …
Run Code Online (Sandbox Code Playgroud)

oauth-2.0 oauth2client google-oauth google-api-python-client gmail-api

3
推荐指数
1
解决办法
2263
查看次数

VIM powerline仅在NERDtree活动的插件时显示

有没有人遇到电源线处于"标准"模式时不显示的问题?

如果我跑:

$ vim ~/.vimrc
Run Code Online (Sandbox Code Playgroud)

我看到以下内容:

"~/.vimrc" 37L, 952C
Run Code Online (Sandbox Code Playgroud)

但是,如果我打开像NERDTree,CtrP或Sytnatstic这样的东西,我能够看到Powerline正如预期的那样,只要我关闭其中一个插件,电源线就会消失.

这是预期的行为吗?

如果有人有兴趣,这是我的.vimrc.

https://gist.github.com/helmutgranda/a8347b5e5f0afe293f11

vim nerdtree

2
推荐指数
1
解决办法
640
查看次数

Robotframework:使用“获取当前日期”以特定格式在运行时获取日期

我正在使用“ 获取当前日期”关键字以年-月-日的格式返回日期。我使用此特定信息来确保在自动测试中帐户创建的时间戳正确。

问题在于无法识别该关键字,我的代码应该正确(它应该可以工作并且应该以我希望的格式产生日期。

*** Keywords ***

Initialize Test Data
    ${DATE}=    Get Current Date    result_format=timestamp
    ${MYNUM}=    faker.Random Int

    Set Suite Variable  ${MYNUM}
    Set Suite Variable  ${DATE}
Run Code Online (Sandbox Code Playgroud)

为什么会出现错误No keyword with name 'Get Current Date' found.

提前致谢。

testing automation date robotframework selenium-webdriver

1
推荐指数
1
解决办法
2万
查看次数

从客户端java脚本打开扩展库对话框

如何从客户端javascript打开扩展库对话框?我用

XSP.openDialog("#{id:myDialog}");
Run Code Online (Sandbox Code Playgroud)

如果我从xPage本身调用它,它的工作原理很完美......但是如何从客户端javaScript库中打开对话框呢?

Error: TypeError: dlg is undefined
Run Code Online (Sandbox Code Playgroud)

我需要从客户端javascript库中的函数调用它:

  <a onclick="return showMyDialog();">Click it</a>
Run Code Online (Sandbox Code Playgroud)

谢谢...

javascript xpages

0
推荐指数
1
解决办法
778
查看次数