我想使用JavaMail和IMAP从Java应用程序访问GMail中的消息.为什么我得到SocketTimeoutException?
这是我的代码:
Properties props = System.getProperties();
props.setProperty("mail.imap.host", "imap.gmail.com");
props.setProperty("mail.imap.port", "993");
props.setProperty("mail.imap.connectiontimeout", "5000");
props.setProperty("mail.imap.timeout", "5000");
try {
Session session = Session.getDefaultInstance(props, new MyAuthenticator());
URLName urlName = new URLName("imap://MYUSERNAME@gmail.com:MYPASSWORD@imap.gmail.com");
Store store = session.getStore(urlName);
if (!store.isConnected()) {
store.connect();
}
} catch (NoSuchProviderException e) {
e.printStackTrace();
System.exit(1);
} catch (MessagingException e) {
e.printStackTrace();
System.exit(2);
}
Run Code Online (Sandbox Code Playgroud)
我设置了超时值,以便不会"永远"超时.此外,MyAuthenticator还具有用户名和密码,这似乎是URL的冗余.还有其他方法来指定协议吗?(我没有在IMD的JavaDoc中看到它.)
在安装openerp 6的过程时,我想用这个命令生成一个配置文件,
cd/home/openerp/openerp-server/bin /
./openerp-server.py -s --stop-after-init -c /home/openerp/openerp-server.cfg
但它总是显示出一个信息
ImportError: No module named psycopg2
当我检查psycopg2包时,它已经安装好,
包python-psycopg2-2.4.5-1.rhel5.x86_64
已安装和最新版本
没事做
这有什么问题?我的服务器是centos,我安装了python 2.6.7.
真的需要你的帮助..
我想account.bank.statement.line
通过其他对象向对象添加行但是我收到此错误:account.bank.statement.line
def action_account_line_create(self, cr, uid, ids):
res = False
cash_id = self.pool.get('account.bank.statement.line')
for exp in self.browse(cr, uid, ids):
company_id = exp.company_id.id
#statement_id = exp.statement_id.id
lines = []
for l in exp.line_ids:
lines.append((0, 0, {
'name': l.name,
'date': l.date,
'amount': l.amount,
'type': l.type,
'statement_id': exp.statement_id.id,
'account_id': l.account_id.id,
'account_analytic_id': l.analytic_account_id.id,
'ref': l.ref,
'note': l.note,
'company_id': l.company_id.id
}))
inv_id = cash_id.create(cr, uid, lines,context=None)
res = inv_id
return res
Run Code Online (Sandbox Code Playgroud)
我改变了它,但后来我遇到了这个错误:
File "C:\Program Files (x86)\OpenERP 6.1-20121029-003136\Server\server\.\openerp\workflow\wkf_expr.py", line 68, in execute
File "C:\Program …
Run Code Online (Sandbox Code Playgroud) 我试图在odoo(以前的OpenERP)中将值插入到many2many或one2manhy关系表中.你知道怎么做吗?
谢谢
我曾经在我未来的应用上展示AdMob横幅广告,并且我想尝试一下插页式广告.
我检查了AdMob SDK的实现,我复制了他们的示例源,因为它正是我想要的(即活动启动时显示的插页式广告).
我在模拟器和我的Galaxy上尝试过,没有显示任何广告.
这是源代码:
public class Asscreed extends Activity {
private InterstitialAd interstitial;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_asscreed);
// Create the interstitial.
interstitial = new InterstitialAd(this);
interstitial.setAdUnitId("ca-app-pub-6046034785851961/xxxxxx");
// Create ad request.
AdRequest adRequest = new AdRequest.Builder().build();
// Begin loading your interstitial.
interstitial.loadAd(adRequest);
}
// Invoke displayInterstitial() when you are ready to display an interstitial.
public void displayInterstitial() {
if (interstitial.isLoaded()) {
interstitial.show();
}
}
}
Run Code Online (Sandbox Code Playgroud)
导入正常,Google Play服务库当然是导入的.
我使用此示例: AdMob Android指南 - 非页内广告.
有人能告诉我我的代码有什么问题吗?
我有以下日期:
2005-08-11T16:34:33Z
Run Code Online (Sandbox Code Playgroud)
我需要知道这个日期是在datetime之前还是之后(2009,04,01),我似乎找不到将该字符串转换为可以将它与日期时间进行比较的方法(2009,04,01) )以有意义的方式.
我有一套2d points
.它们X,Y coordinates
位于标准的笛卡尔网格系统上(在本例中为a UTM zone
).我需要在该点集中找到孔,最好能够设置找到这些孔的算法的灵敏度.通常这些点集非常密集,但有些可能密度低得多.
它们是什么,如果它有帮助的话,那就是田地里的土壤被采样的点,农业人们显然发现它们有用.有时在这些点样品中有巨大的岩石或沼泽地或满是小湖泊和池塘.
从点集中,他们希望我找到粗略定义这些孔的凹多边形.
我已经编写了找到外部凹面边界多边形的算法,并允许它们设置由算法形成的多边形粗糙或平滑的灵敏度.在那之后,他们想找到洞并将那些洞作为凹多边形给予它们,我猜在某些情况下可能是凸的,但这将是边缘情况而不是常态.
问题是我听过的关于这个问题的唯一论文是那些希望在太空中找到大空虚的天文学家完成的论文,我从来没有能够找到他们的一篇论文,其中的实际算法显示为除了粗略的概念描述之外的任何东西
我已经尝试了谷歌和各种学术论文搜索等,但到目前为止我还没有找到很多有用的东西.这让我想知道是否有这个问题的名字,我不知道所以我在寻找错误的东西或什么?
所以经过那个冗长的解释之后,我的问题是:有没有人知道我应该寻找什么,最好用定义明确的算法找到这方面的论文,或者有人知道一个他们可以指出我的算法吗?
任何帮助我解决这个问题的东西都会非常有用并且非常感激,即使只是正确的搜索短语,也会发现潜在的算法或论文.
这将实现的语言将是C#,但是从Mathematica软件包到其他任何东西的例子MATLAB or ASM, C, C++, Python, Java or MathCAD
都可以,只要示例中没有一些调用就像是FindTheHole
等等.FindTheHole
没有定义或者是对于实现软件而言是专有的,例如,MathCAD
示例通常具有很多.
下面是两个实际点集的例子,一个是密集的,一个是稀疏的,我需要找到它们中的区域:
我正在尝试在jinja模板中编写if语句
{% for key in data %}
{% if key is 'priority' %}
<p>('Priority: ' + str(data[key])</p>
{% endif %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
我试图在python中翻译的声明是
if key == priority:
print(print('Priority: ' + str(data[key]))
Run Code Online (Sandbox Code Playgroud)
这是我得到的错误:
TemplateSyntaxError:期望令牌'name',得到'string'
在Android WebView的loadDataWithBaseURL方法中,有"baseUrl"和"historyUrl".
它们用于什么?
我已经阅读了android文档,但仍然不知道它们是什么.
我正在尝试使用目标c中的参数调用一个简单的JSON Web服务.到目前为止不起作用.
这是Web服务方法:
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public void LogIn(string username, string password)
{
Context.Response.Write(username + "___" + password);
Context.Response.End();
}
Run Code Online (Sandbox Code Playgroud)
这是我的Objective C代码:
// Build dictionnary with parameters
NSString *username = @"usernameTest";
NSString *password = @"passwordTest";
NSMutableDictionary *dictionnary = [NSMutableDictionary dictionary];
[dictionnary setObject:username forKey:@"username"];
[dictionnary setObject:password forKey:@"password"];
NSError *error = nil;
NSData *jsonData = [NSJSONSerialization dataWithJSONObject:dictionnary
options:kNilOptions
error:&error];
NSString *urlString = @"http://localhost:8080/ListrWS.asmx/LogIn";
NSURL *url = [NSURL URLWithString:urlString];
// Prepare the request
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
[request setHTTPMethod:@"POST"];
[request setValue:@"application/json" …
Run Code Online (Sandbox Code Playgroud)