小编Sim*_*gwi的帖子

芹菜 - 以编程方式列出工人

如何使用Python代码以编程方式列出当前工作程序及其相应的celery.worker.consumer.Consumer实例?

python celery

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

获取旋转图像中某点的新x,y坐标

我有谷歌地图图标,我需要在使用MarkerImage在地图上绘制之前按特定角度旋转.我使用PIL在Python中即时轮换,结果图像与原始图像大小相同 - 32x32.例如,使用以下默认的Google地图标记: 旋转前的图标 ,使用以下python代码实现30度顺时针旋转:

# full_src is a variable holding the full path to image
# rotated is a variable holding the full path to where the rotated image is saved
image = Image.open(full_src)
png_info = image.info
image = image.copy()
image = image.rotate(30, resample=Image.BICUBIC)
image.save(rotated, **png_info)
Run Code Online (Sandbox Code Playgroud)

得到的图像是 图标逆时针旋转30度

棘手的一点是在使用新的旋转图像创建MarkerImage时使用新的锚点.这需要是图标的尖端.默认情况下,锚点是底部中间[在x,y坐标中定义为(16,32),其中(0,0)是左上角].有人可以向我解释如何在JavaScript中轻松解决这个问题吗?

谢谢.

2011年6月22日更新: 发布了错误的旋转图像(原始图像是逆时针旋转330度).我已经纠正了这一点.还添加了重采样(Image.BICUBIC),使旋转的图标更清晰.

javascript python api google-maps image-rotation

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

django-celery:动态创建并注册任务

我想用延迟添加任意任务django-celery.目前,我已经创建了一个类似于下面的类(只是一个例子,实际的类有更多):

from celery.task import task

class Delayer(object):
    def delay(self, func, minutes):
        return task(func, name="%s.delayed"%self.__class__.__name__)\
            .apply_async(countdown=minutes*60)
Run Code Online (Sandbox Code Playgroud)

我正在运行芹菜如下:

python manage.py celeryd -E -B -lDEBUG
Run Code Online (Sandbox Code Playgroud)

当我尝试从django shell [例如Delayer().delay(lambda: 1, 1)]中运行我的延迟方法时,我在我的celeryd输出中遇到这样的错误:

[2013-01-02 15:26:39,324: ERROR/MainProcess] Received unregistered task of type "Delayer.delayed".
The message has been ignored and discarded.

Did you remember to import the module containing this task?
Or maybe you are using relative imports?
Please see http://bit.ly/gLye1c for more information.

The full contents of the message body was:
{'retries': 0, …
Run Code Online (Sandbox Code Playgroud)

django celery

10
推荐指数
1
解决办法
4493
查看次数

标签 统计

celery ×2

python ×2

api ×1

django ×1

google-maps ×1

image-rotation ×1

javascript ×1