我是emacs的新手,并开始学习如何有效地使用它.
我想要使用的第一件事是svn模式.
我下载了psvn.el并将其放在〜/ .emacs.d目录中
然后按照psvn.el文件的注释部分中的说明,我把这一行
(require 'psvn)
Run Code Online (Sandbox Code Playgroud)
进入.emacs文件
这是我当前的.emacs文件
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(inhibit-startup-screen t))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file …Run Code Online (Sandbox Code Playgroud) 这是一个示例代码
package org.example;
import java.lang.reflect.Method;
class TestRef {
public void testA(String ... a) {
for (String i : a) {
System.out.println(i);
}
}
public static void main(String[] args){
Class testRefClass = TestRef.class;
for (Method m: testRefClass.getMethods()) {
if (m.getName() == "testA") {
System.out.println(m);
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
输出是
public void org.example.TestRef.testA(java.lang.String[])
Run Code Online (Sandbox Code Playgroud)
因此,报告该方法的签名采用String数组.
在反射库中是否有任何意思我可以告诉该方法最初被声明为采用varargs?
在我的python环境中,已经安装了Rpy和Scipy包.
我想解决的问题是这样的:
1)大量财务数据存储在文本文件中.无法加载到Excel
2)我需要总结某些字段并得到总数.
3)我需要根据总数显示前10行.
哪个包(Scipy或Rpy)最适合此任务?
如果是这样,你能否提供一些可以帮助我实施解决方案的指针(例如文档或在线示例)?
速度是一个问题.理想情况下scipy和Rpy可以处理大文件,即使文件太大而无法安装到内存中
当我在XCode 6.0.1中创建一个新项目时,我收到此错误消息:文件"exclude"不存在

它似乎只会影响文件的版本控制,即生成项目后生成的存根文件不会提交到github.
什么可能导致这个问题?
我正在寻找概念层面的答案.因此,请不要简单地提供aws文档的链接作为答案.
这是boto生成预制策略的方式
@staticmethod
def _canned_policy(resource, expires):
"""
Creates a canned policy string.
"""
policy = ('{"Statement":[{"Resource":"%(resource)s",'
'"Condition":{"DateLessThan":{"AWS:EpochTime":'
'%(expires)s}}}]}' % locals())
return policy
Run Code Online (Sandbox Code Playgroud)
它是同一个库生成自定义策略的方式
@staticmethod
def _custom_policy(resource, expires=None, valid_after=None, ip_address=None):
"""
Creates a custom policy string based on the supplied parameters.
"""
condition = {}
# SEE: http://docs.amazonwebservices.com/AmazonCloudFront/latest/DeveloperGuide/RestrictingAccessPrivateContent.html#CustomPolicy
# The 'DateLessThan' property is required.
if not expires:
# Defaults to ONE day
expires = int(time.time()) + 86400
condition["DateLessThan"] = {"AWS:EpochTime": expires}
if valid_after:
condition["DateGreaterThan"] = …Run Code Online (Sandbox Code Playgroud) 在我的包中,我需要部署一些辅助 js 和 json 文件。
在我的 MANIFEST.IN 文件中,我指定了:
include config/*.json
include bin/*.js
include lib/*.js
Run Code Online (Sandbox Code Playgroud)
运行后python setup.py sdist,我tar txvf dist/mypackage-1.2.1.tar.gz用来检查内容。我可以看到json和js文件。
但是,当我运行时pip install /path/to/sdist/file/mypackage-1.2.1.tar.gz,它只会将 python 文件安装到该site-packages/mypackage位置。我需要做什么来复制其他文件?
import os
import shutil
import subprocess
import json
from setuptools import setup
from setuptools.command.install import install
from distutils.sysconfig import get_python_lib
class Installer(install):
def run(self):
install.run(self)
install_folder = '%s/mypackage' % get_python_lib()
# Just to check what I got
for n, ds, fs in os.walk(install_folder):
print n, d, fs
setup(name='mypackage', …Run Code Online (Sandbox Code Playgroud) 以下是 IntelliJ IDEA 中 typescript 服务的配置:
服务不断崩溃并重生,这是日志输出
Process: TypeScript service version: 3.2.1
Process: Default service options: {"baseUrl":"/Users/antkong/dev/myproject/src","experimentalDecorators":true,"importHelpers":false,"jsx":2,"lib":["lib.dom.d.ts","lib.dom.iterable.d.ts","lib.es2018.d.ts"],"moduleResolution":2,"outDir":"/Users/antkong/dev/myproject/target","strict":true,"skipLibCheck":true,"target":2,"sourceMap":true,"module":6,"configFilePath":"/Users/antkong/dev/myproject/tsconfig.json"}
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
1: 0x1000389cc node::Abort() [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
2: 0x100038ba8 node::FatalTryCatch::~FatalTryCatch() [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
3: 0x1001a9d5a v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
4: 0x100578772 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
5: 0x100577729 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
6: 0x1005753b8 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
7: 0x1005818fc v8::internal::Heap::AllocateRawWithRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
8: 0x100550294 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/Users/antkong/.nvm/versions/node/v10.7.0/bin/node]
9: 0x1007daf84 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) …Run Code Online (Sandbox Code Playgroud) 由于超时问题,terraform 无法创建 ec2 实例。
为了从中恢复,我已从 aws 控制台手动删除了 ec2 实例以及 terraform 状态文件。
然而现在它试图重新创建
+ aws_iam_instance_profile.server
id: <computed>
arn: <computed>
create_date: <computed>
name: "server-profile"
path: "/"
role: "server-role"
roles.#: <computed>
unique_id: <computed>
Run Code Online (Sandbox Code Playgroud)
因此我想在 aws 控制台中找到它并将其删除。然而我不知道在哪里可以找到它。
我可以在哪里找到aws_iam_instance_profile.server?
简介:当导入某个python模块时,我希望能够拦截这个动作,而不是加载所需的类,我想加载我选择的另一个类.
原因:我正在研究一些遗留代码.在开始一些增强/重构之前,我需要编写一些单元测试代码.但是,代码会导入某个模块,该模块在单元测试设置中会失败.(由于数据库服务器依赖性)
Pseduo代码:
from LegacyDataLoader import load_me_data
...
def do_something():
data = load_me_data()
Run Code Online (Sandbox Code Playgroud)
因此,理想情况下,当python在单元测试中使用上面的导入行时,会加载替代类MockDataLoader.
我还在使用2.4.3.我想有一个我可以操纵的导入钩子
编辑
非常感谢到目前为止的答案.他们都非常有帮助.
一种特殊类型的建议是关于操纵PYTHONPATH.它在我的情况下不起作用.所以我将在这里阐述我的具体情况.
原始代码库以这种方式组织
./dir1/myapp/database/LegacyDataLoader.py
./dir1/myapp/database/Other.py
./dir1/myapp/database/__init__.py
./dir1/myapp/__init__.py
Run Code Online (Sandbox Code Playgroud)
我的目标是在Other模块中增强Other类.但是因为它是遗留代码,所以如果不首先将测试套件捆绑在一起,我会感到很自在.
现在我介绍一下这个单元测试代码
./unit_test/test.py
Run Code Online (Sandbox Code Playgroud)
内容很简单:
from myapp.database.Other import Other
def test1():
o = Other()
o.do_something()
if __name__ == "__main__":
test1()
Run Code Online (Sandbox Code Playgroud)
当CI服务器运行上述测试时,测试失败.这是因为类Other使用LegacyDataLoader,而LegacydataLoader无法从CI框建立与数据库服务器的数据库连接.
现在让我们按照建议添加一个假类:
./unit_test_fake/myapp/database/LegacyDataLoader.py
./unit_test_fake/myapp/database/__init__.py
./unit_test_fake/myapp/__init__.py
Run Code Online (Sandbox Code Playgroud)
将PYTHONPATH修改为
export PYTHONPATH=unit_test_fake:dir1:unit_test
Run Code Online (Sandbox Code Playgroud)
现在测试失败了另一个原因
File "unit_test/test.py", line 1, in <module>
from myapp.database.Other import Other
ImportError: No module named Other
Run Code Online (Sandbox Code Playgroud)
它与python解析模块中的类/属性的方式有关
在我的app.yaml中,网址被定义为:
- url: /api/.*
script: main.app
login: admin
secure: always
Run Code Online (Sandbox Code Playgroud)
我尝试使用以下代码与api交谈
import requests
def main():
r = requests.get("https://test.appspots.com/api/get_data", auth=('me@me.com', 'password'))
print r.status_code, r.text
if __name__ == '__main__':
main()
Run Code Online (Sandbox Code Playgroud)
但身份验证失败了,从输出判断,我重定向到登录页面.
如何使用python进行身份验证和访问URL?
python ×4
cygwin ×1
emacs ×1
java ×1
node.js ×1
numpy ×1
pip ×1
python-2.7 ×1
r ×1
scipy ×1
setuptools ×1
terraform ×1
unit-testing ×1
xcode6 ×1
xcode6.0.1 ×1