小编Ast*_*tar的帖子

Google Cloud Functions (GCF) - 使用 apt-get 安装软件包

我需要 2 个软件包才能使我的Google Cloud Functions (GCF)功能正常工作。我通常会在 Ubuntu 上使用以下命令安装它们:

apt-get -y install firefox xvfb
Run Code Online (Sandbox Code Playgroud)

但是,我不知道如何打包我的函数,这会指示 GCF 在运行我的代码之前下载这些包。

我尝试使用subprocess.call()从我的 Python 函数中安装它们。

这是一些代码:

try:
    print(subprocess.check_output("apt-get -y install firefox", shell=True, stderr=subprocess.STDOUT))
except subprocess.CalledProcessError as e:
    print("Ping stdout output:\n", e.output)

try:
    print(subprocess.check_output("apt-get -y install xvfb", shell=True, stderr=subprocess.STDOUT))
except subprocess.CalledProcessError as e:
    print("Ping stdout output:\n", e.output)
Run Code Online (Sandbox Code Playgroud)

不幸的是,这不起作用。我收到以下错误:

Reading package lists...
Building dependency tree...
Reading state information...
The following additional packages will be installed:
 libcanberra0 libdbusmenu-gtk3-4 libstartup-notification0 libtdb1
 libxcb-util1 sound-theme-freedesktop xul-ext-ubufox
Suggested packages:\n …
Run Code Online (Sandbox Code Playgroud)

firefox python-3.x xvfb google-cloud-platform google-cloud-functions

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

Firebase 侦听器在 Android 设备上不起作用(有时)

我的 firebase 侦听在 iOS(设备和模拟器)和Android 模拟器上完美运行。

当连接到真正的 android 设备时,侦听器有时不会触发。

我该如何去调试这个?

当 firebase 侦听器不工作时, firebase auth() 函数正在工作。因此,我可以对用户进行身份验证,但无法使用.on listener检索数据。

例如,

firebase.auth().signInAndRetrieveDataWithEmailAndPassword(email, pass)
.then(() => {
    console.log('this prints every time');
})
.catch(function (error) {
    console.log(error);
});

firebase.auth().onAuthStateChanged((user) => {
    if (user) {
        firebase.database().ref().on('value', (snapshot) => {
            console.log('This never prints')
        });
    }
}
Run Code Online (Sandbox Code Playgroud)

。对听者不火,但认证工作

这只是有时发生,通常等待几个小时,然后再试一次,它就会消失。然后它会再次回来。

编辑:在应用程序打开的情况下等待一个多小时后,firebase 侦听器实际上起作用了。但是,花了一个多小时。还是不明白为什么...

编辑:在 Android Studio 的 logcat 中找到这些日志。这组相同的消息一遍又一遍地重复。

编辑:当使用移动热点连接到互联网时,问题不会发生...

09-23 22:25:47.920 21028-21146/com.starco.starmsg D/PersistentConnection: pc_0 …
Run Code Online (Sandbox Code Playgroud)

javascript firebase reactjs react-native firebase-realtime-database

5
推荐指数
0
解决办法
758
查看次数