小编sha*_*kra的帖子

通过DLNA/UPnP流媒体文件

我目前正在我的Raspberry Pi上运行Raspbmc并激活UPnP流式渲染.

我的目标是编写一个简单的Python来流式传输视频或音乐播放列表.

我已经尝试过Coherence,但是它引起了一些例外,我并没有真正理解这一点,因为文档非常混乱.所以我正在寻找一种更简单的方法/库.

使用Python将媒体文件流式传输到电视的最简单方法是什么?

python streaming upnp dlna

14
推荐指数
2
解决办法
6694
查看次数

未定义:grpc.SupportPackageIsVersion7 grpc.ServiceRegistrar

在 docker 内部,由于此错误,我似乎无法编译我的 gRPC 微服务:

Step 4/9 : RUN make build
 ---> Running in ceb6e4d0e19b
protoc --version
libprotoc 3.12.4
protoc --proto_path=pkg/proto/notify/ --go_out=pkg/proto/notify/ --go-grpc_out=pkg/proto/notify/ --go_opt=paths=source_relative --go-grpc_opt=paths=source_relative notify.proto

plugin versions reported in *.pb.go files:
./pkg/proto/notify/notify.pb.go://  protoc-gen-go v1.25.0-devel
./pkg/proto/notify/notify.pb.go://  protoc        v3.12.4

go build -o notify-service *.go
go: downloading github.com/lib/pq v1.7.0
go: downloading google.golang.org/grpc v1.27.0
go: downloading github.com/jinzhu/gorm v1.9.14
go: downloading github.com/aws/aws-sdk-go v1.33.7
go: downloading github.com/go-kit/kit v0.10.0
go: downloading google.golang.org/protobuf v1.25.0
go: downloading github.com/go-co-op/gocron v0.2.1
go: downloading github.com/sirupsen/logrus v1.6.0
go: downloading github.com/golang/protobuf v1.4.2
go: …
Run Code Online (Sandbox Code Playgroud)

go protocol-buffers docker

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

SqlAlchemy按时差过滤

我是SQLAlchemy的新手(但不是那么新).我正在使用0.9.3版本的项目.我想对SQLite数据库进行查询,过滤结果以获取那些没有时间戳的对象,或者自上次更新后超过24小时(在同一列上).

问题是,我没有确切知道如何实现时间过滤部分,我做了一个IPython Notebook会话,所以人们可以看看尝试寻找我的问题的答案有多长:

在[1]中:

from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy import Column, Unicode, DateTime, Integer, create_engine
from sqlalchemy.orm import sessionmaker, relationship, backref
from datetime import datetime

engine = create_engine('sqlite:///:memory:')
Base = declarative_base()
Session = sessionmaker(bind=engine)
session = Session()
Run Code Online (Sandbox Code Playgroud)

在[2]中:

class Product(Base):
    __tablename__ = "product"

    id = Column(Integer, primary_key=True)
    name = Column(Unicode(140), unique=True, nullable=False)
    department = Column(Unicode(20))
    added = Column(DateTime, default=datetime.now)
    last_time_parsed = Column(DateTime)

    def repr(self):
        return "<Product(name=%s, department=%s, added=%s, last_time_parsed=%s)>" % (
                            self.name, self.department, self.added, self.last_time_parsed)
Run Code Online (Sandbox Code Playgroud)

在[3]中:

# create the …
Run Code Online (Sandbox Code Playgroud)

python time orm sqlalchemy python-datetime

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

Wercker设置环境耗时太长,导致构建失败

我制作了一个docker镜像,将它与我在Wercker中的项目构建一起使用,我这样做是因为我认为已经在环境中安装了需要的包比在我的项目的每个版本中安装它们要好.

但是,现在Wercker每次都必须构建我的项目失败,原因是什么?超时,因为设置环境步骤需要超过5分钟.

Running wercker version: 1.0.405 (Compiled at: 2016-02-10T22:17:21Z, Git commit: b44ceb57f107c85dbaa619c6d89592b979f69b5b)
Using config:
box: shackra/latex-ebook
build:
steps:
- script:
name: Documento en formato PDF
code: |
xelatex --version
# twice, please
xelatex biblia.tex
xelatex biblia.tex
- script:
name: Subir documentos a Bitbucket
code: |
./upload-to-bitbucket.sh $BITBUCKET_U $BITBUCKET_P /straubingerdigital/biblia-platense/downloads biblia.pdf

Pulling from shackra/latex-ebook: latest
Pulling fs layer: e627a276e4dc
Pulling fs layer: 16c1e3a61000
Pulling fs layer: 80bc33a4179a
Pulling fs layer: d23822bfcf6d
Pulling fs layer: 4fdf7f1f2966
Pulling fs layer: f6a9cd9eb099 …
Run Code Online (Sandbox Code Playgroud)

docker wercker

7
推荐指数
0
解决办法
317
查看次数

如果使用 axios 刷新令牌已过期,则正确重定向用户

我在项目的前端使用 Axios,需要一种方法将用户重定向到登录页面,以防他想使用过期的令牌(刷新令牌对后端无效),在web 看起来很容易适应我的技术堆栈(没有 Redux 的 ReactJS):

\n\n
import axios from \'axios\';\n\n// additional code that lives in its own module\nconst getToken = () => {\n  return isAuth() ? window.localStorage.getItem("token") : "";\n};\n\nconst getRefreshToken = () => {\n  return isAuth() ? window.localStorage.getItem("refresh_token") : "";\n};\n\nconst setTokens = (token, refresh) => {\n  window.localStorage.setItem("token", token);\n  window.localStorage.setItem("refresh_token", refresh);\n};\n// this is on my app.js file\naxios.interceptors.response.use(function (response) {\n  return response;\n}, function (error) {\n  const originalRequest = error.config;\n  if (error.response.status === 401 && !originalRequest._retry) {\n    originalRequest._retry = true;\n …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs axios

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

装饰方法:AttributeError: 'function' object has no attribute '__self__'?

我正在处理以asyncio特定的相对时间间隔调用的调度方法。我决定将调度集中到我编写的类的一种方法中,以减少我的项目逻辑出错的机会。

每次计划方法完成时都应调用此类方法。我虽然在loop.call_soon每个方法的末尾添加,但我决定试一试装饰器

我写了一个类装饰器,然后将它应用于我的主类的一些方法,编写其余的逻辑等等。但是当我尝试在我的项目上测试我的更改时,我得到了一个例外:

AttributeError: 'function' object has no attribute '__self__'
Run Code Online (Sandbox Code Playgroud)

不知何故,装饰我的方法使它成为一个功能。这是我无法理解的事情,为什么会发生这种情况?如何在不放弃装饰器的情况下解决这个问题?

这是我正在尝试做的一个最小、完整且可验证的示例:

import asyncio
from datetime import datetime


class thinkagain:
    loop = asyncio.get_event_loop()

    def __init__(self, f):
        self.fun = f
        self.class_ = f.__self__

    def __call__(self):
        self.fun(*args, **kwords)
        # everything in Python is an object
        setattr(self.fun, "called", datetime.utcnow())
        self.loop.call_later(self.class_.think, 5 * 60)


class DoSomething:
    loop = asyncio.get_event_loop()

    @thinkagain
    def think(self):
        attr = getattr(self.dosomething, "called")
        if attr:
            elapsed = attr - datetime.utcnow()
            seconds = elapsed.seconds
        else:
            seconds …
Run Code Online (Sandbox Code Playgroud)

python python-3.x python-decorators

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

如Sublime Text中那样转置两个单词

我正在观看一个Django的在线课程,老师在Sublime Text中用一个列表的两个值做了一个很好的技巧,它将每个值转换到另一个的位置,例如:

list = ("foo", "bar", "hello")
Run Code Online (Sandbox Code Playgroud)

标记foobar用鼠标然后进行转置,得到以下内容:

list = ("bar", "foo", "hello")
Run Code Online (Sandbox Code Playgroud)

如何在Emacs中实现?

emacs emacs24 sublimetext2

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

导入别名在 craco 的 creat-react-app 中无法按预期工作

编辑:为了遵守 Stackoverflow 指南并让我们所有人都轻松,我提交了一个可重现的小示例来重现我的错误:

\n

https://github.com/shackra/stackoverflow-alias-bug

\n

编辑2:如果这有帮助,我正在使用asdf版本v0.8.0-c6145d0来管理我的nodejs安装:

\n
~ $ whereis node\nnode: /usr/bin/node /usr/include/node /home/jorge/.asdf/shims/node /usr/share/man/man1/node.1.gz\n~ $ node --version\nv14.2.0\n~ $ whereis yarn\nyarn: /home/jorge/.asdf/shims/yarn\n~ $ whereis npm\nnpm: /usr/bin/npm /home/jorge/.asdf/shims/npm /usr/share/man/man1/npm.1\n
Run Code Online (Sandbox Code Playgroud)\n
\n

对于现有的 React 项目,我使用了 CRA,现在消除了大多数错误,但是在调试问题几个小时后我无法使我的别名正常工作:

\n
npm run build\n\n> frontend@0.1.0 prebuild /home/jorge/code/kue/fero/dev/frontend\n> nps generate-build-version\n\nnps is executing `generate-build-version` : nps genver\nnps is executing `genver` : deno run --allow-read --allow-write generate-build-version.ts\n\n> frontend@0.1.0 build /home/jorge/code/kue/fero/dev/frontend\n> nps build\n\nnps is executing `build` : craco build\ncraco:  *** Cannot …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs

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

如何用ant-design useForm查询字段值?

我有这个表单,我想根据其他已修复字段(它们从不隐藏)的值来显示或隐藏字段,但form.getFieldValue("some-field")始终使用 return undefined

这是一个最小的功能示例,展示了我遇到的问题:

编辑 爱-almeida-tb1h2

我对 antd 做错了什么以及如何实现我的用例?

reactjs antd

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