我有一个用Ant构建的构建脚本,它有一个macrodef,它接受一些默认参数,target,root等,然后是一个可选的两个,extrasrc-f和extrasrc-c.在他们进来之后,我喜欢对所有相关资源进行最新检查,然后只在目标过期时才进行构建.
我现在拥有的是什么
<?xml version="1.0" encoding="UTF-8"?>
<project name="Custom build" default="default">
<taskdef resource="net/sf/antcontrib/antlib.xml"
classpath="C:/dev/ant/ant-contrib/ant-contrib-1.0b3.jar"/>
<macrodef name="checkuptodate">
<attribute name="target" />
<element name="resource" />
<sequential>
<condition property="needbuild">
<and>
<resourcecount when="greater" count="0"> <resource /> </resourcecount>
<not>
<uptodate targetfile="@{target}">
<srcresources> <resource /> </srcresources>
</uptodate>
</not>
</and>
</condition>
</sequential>
</macrodef>
<macrodef name="projbuild">
<attribute name="root" />
<attribute name="target" />
<element name="extrasrc-f" optional="true" />
<element name="extrasrc-c" optional="true" />
<sequential>
<local name="needbuild" />
<checkuptodate target="@{root}/bin/@{target}">
<resource>
<union>
<extrasrc-f />
<fileset dir="@{root}/src" includes="**/*.java" />
</union>
</resource>
</checkuptodate>
<if>
<istrue value="${needbuild}" /> …Run Code Online (Sandbox Code Playgroud) 我将数十万条JSON记录发布到MAX数据上传限制为1MB的服务器上.我的记录大小可以变化,从几百字节到几十万字节不等.
def checkSize(payload):
return len(payload) >= bytesPerMB
toSend = []
for row in rows:
toSend.append(row)
postData = json.dumps(toSend)
tooBig = tooBig or checkSize()
if tooBig:
sendToServer(postData)
Run Code Online (Sandbox Code Playgroud)
然后发布到服务器.它目前有效,但是对于一个jsonified字符串的持续倾销看起来真的很重,几乎100%太多了,虽然我似乎无法找到另一种方法.我是否可以将各个新记录串联起来并记录它们在一起的内容?
我敢肯定必须有一个更清洁的方式,但我只是不知道.
感谢您给予的任何和所有帮助.
这就是我现在使用的答案,我在下面与@rsegal同时提出它,只是为了清晰和完成而发布(sendToServer只是一个虚拟函数来显示工作正常),
import pickle
import json
f = open("userProfiles")
rows = pickle.load(f)
f.close()
bytesPerMB = 1024 * 1024
comma = ","
appendSize = len(comma)
def sendToServer(obj):
#send to server
pass
def checkSize(numBytes):
return numBytes >= bytesPerMB
def jsonDump(obj):
return json.dumps(obj, separators=(comma, ":"))
leftover = []
numRows = len(rows)
rowsSent = 0
while …Run Code Online (Sandbox Code Playgroud) 我目前正在自动化构建脚本以将资源推送到亚马逊s3并使用http://s3tools.org/s3cmd(和https://github.com/s3tools/s3cmd),我理解这是正常/主命令行工具使用.没有什么太复杂,而且我已经完成了大部分的测试,但是当我进入那里时,整个事情开始分崩离析,我很困惑为什么.
一个简单的命令(在s3上存在'mybucket',在我运行命令的目录中存在'file.ext'),
s3cmd put file.ext s3://mybucket/
Run Code Online (Sandbox Code Playgroud)
两者都失败了
[Errno 104] Connection reset by peer
Run Code Online (Sandbox Code Playgroud)
要么
[Errno 32] Broken pipe
Run Code Online (Sandbox Code Playgroud)
我知道s3的大小超过5GB的文件存在问题,但是这些文件远不及它,它们不到1MB,更不用说超过1GB.真正奇怪的是,另一个程序,http://www.bucketexplorer.com/在同一个网络上完美地完成了相同的操作.
什么是怪异仍然是检验一切的时候,我拴我的笔记本电脑到手机的3G连接,马上一切再完美的工作,当我回到家,并测试了命令又出现,就再完美的工作.
知道在我们的工作网络中可能导致此错误的是什么,使用s3cmd,但不是Bucket Explorer?
我刚刚遇到一个正在运行的应用程序的一些unicode错误,每次都要处理非常奇怪的字符串,最近,
P?nar Kars?yaka
Run Code Online (Sandbox Code Playgroud)
在我的开发环境中(Aptana w.PyDev on Mavericks Mac上有一个最新的自制软件安装),处理这个字符串不会产生错误,并打印到控制台
P\u0131nar Kars\u0131yaka v Torku Selcuk
Run Code Online (Sandbox Code Playgroud)
但是在生产环境中,标准的Ubuntu和Python安装在Amazon EC2小盒子上,打印得像
P\xc4\xb1nar Kars\xc4\xb1yaka v Torku Selcuk
Run Code Online (Sandbox Code Playgroud)
并给出一个可怕的Python错误,
UnicodeEncodeError: 'ascii' codec can't encode character u'\u0131' in position 50: ordinal not in range(128)
Run Code Online (Sandbox Code Playgroud)
我想知道如何(如果可能的话)使prod环境能够处理这些字符,比如我的开发环境可以,但也希望能够改变我的开发环境,像prod一样打破,所以我可以处理代码中发生这种情况的事件.
感谢您对此提供任何帮助.
Mac Python - Python 2.7.5(默认,2013年11月1日,18:38:34)[GCC 4.2.1兼容的Apple LLVM 5.0(clang-500.2.79)]在达尔文
Ubuntu Python - Python 2.7.3(默认,2013年4月10日,06:20:15)[gCC 4.6.3]在linux2上
python development-environment production-environment python-unicode
如果您有Facebook,例如Zuckerbergs用户ID'4'或用户名'zuck',您如何Graph v2.0使用应用程序的访问令牌获取新的应用程序范围ID ?似乎无法在文档中找到任何相关内容.
我们Robolectric在我们的SDK上使用UnitTests,但有一件事我注意到,当我们运行我们的测试时,这绝对会使日志变得混乱(Jenkins当你运行近200个测试时,这尤其是一个问题).
我们所有测试开始的一个例子是,
@RunWith(RobolectricGradleTestRunner.class)
@Config(constants = BuildConfig.class, emulateSdk=21)
public class AppTest {
private MainActivity activity;
@Before
public void setUp() throws Exception {
activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().visible().get();
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我们跑过去的时候,
activity = Robolectric.buildActivity(MainActivity.class).create().start().resume().visible().get();
我们在日志中得到了这个,
18:56:02 W/InputEventReceiver: Attempted to consume batched input events but the input event receiver has already been disposed.
18:56:02 W/InputEventReceiver: Attempted to consume batched input events but the input event receiver has already been disposed.
18:56:02 W/InputEventReceiver: Attempted to consume batched input events but the input …
我一直在使用 SQLAlchemy 和 Alembic 来简化我使用的数据库访问,以及我对表所做的任何数据结构更改。这一直很有效,直到我开始注意到越来越多的 SQLAlchemy“过期”字段问题,从我的角度来看,几乎是随机的。
一个恰当的例子是这个片段,
class HRDecimal(Model):
dec_id = Column(String(50), index=True)
@staticmethod
def qfilter(*filters):
"""
:rtype : list[HRDecimal]
"""
return list(HRDecimal.query.filter(*filters))
class Meta(Model):
dec_id = Column(String(50), index=True)
@staticmethod
def qfilter(*filters):
"""
:rtype : list[Meta]
"""
return list(Meta.query.filter(*filters))
Run Code Online (Sandbox Code Playgroud)
代码:
ids = ['1', '2', '3'] # obviously fake list of ids
decs = HRDecimal.qfilter(
HRDecimal.dec_id.in_(ids))
metas = Meta.qfilter(
Meta.dec_id.in_(ids))
combined = []
for ident in ids:
combined.append((
ident,
[dec for dec in decs if dec.dec_id == ident],
[hm for hm …Run Code Online (Sandbox Code Playgroud) 我有一个〜1mil行的DataFrame,以及~100k个独特事件.有1列Won,每个事件1行设置为True,事件中的每一行设置为False.
即
Event ID Runner ID Won
E1 R1 True
E1 R2 False
E1 R3 False
E2 R4 True
E2 R5 False
E2 R6 False
Run Code Online (Sandbox Code Playgroud)
我最终想要的是一个平衡的DataFrame,只有1个赢家,每组只有1个非赢家.
即
Event ID Runner ID Won
E1 R1 True
E1 R3 False
E2 R4 True
E2 R5 False
Run Code Online (Sandbox Code Playgroud)
我不关心每个赛事选择哪个非冠军,只要有1个冠军,一个非冠军.
有了熊猫,我尝试了一些事情,选择获胜者和非获胜者,
_won = df.Won
winners = df[_won]
non_winners = df[~_won]
Run Code Online (Sandbox Code Playgroud)
但是我所看到的每个过程,并试图选择每场比赛1名非胜利者的速度非常慢 - 每场比赛只需几秒钟(当你有100k赛事时,IMO是不合理的).
一次性group和apply,和
new_df = winners.append(
non_winners
.groupby('Event ID')
.apply(lambda grp: grp.sample(1))
Run Code Online (Sandbox Code Playgroud)
迭代groupby,
for event_id, grp in non_winners.groupby('Event …Run Code Online (Sandbox Code Playgroud) 对于我们的游戏,在 Info.plist 文件中,我们的CFBundleIdentifier设置为,
<key>CFBundleIdentifier</key>
<string>com.sixminute.$(PRODUCT_NAME:rfc1034identifier)</string>
Run Code Online (Sandbox Code Playgroud)
但是,对于 Google Play 登录,我们需要以下 URL 类型CFBundleURLTypes,
<key>CFBundleURLName</key>
<string>com.sixminute.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleURLSchemes</key>
<array>
<string>com.sixminute.$(PRODUCT_NAME:rfc1034identifier)</string>
</array>
Run Code Online (Sandbox Code Playgroud)
有什么方法我们可以代替引用CFBundleIdentifier动态的类似$(BUNDLE_IDENTIFIER)或类似的东西吗?