我正在尝试以另一个用户身份运行命令并以该用户身份读取输入.由于某种原因,脚本不会暂停read命令,我不确定为什么.这是脚本的一个例子:
#!/bin/bash
username='anthony'
sudo -H -u "$username" bash << 'END_COMMAND'
# Commands to be run as new user
# -------------------------------
echo "#! Running as new user $USER..."
echo "#! Gathering setup information for $USER..."
echo -n "Enter your name and press [ENTER]: "
read name
echo -n "Enter your email and press [ENTER]: "
read email
END_COMMAND
echo "Done"
Run Code Online (Sandbox Code Playgroud)
关于为什么这不停止read name或任何想法read email?
我正在尝试使用Selenium(在Python中)从网站中提取一些信息.我一直在选择带有XPath的元素,但是在使用以下兄弟选择器时遇到了麻烦.HTML如下:
<span class="metadata">
<strong>Photographer's Name: </strong>
Ansel Adams
</span>
Run Code Online (Sandbox Code Playgroud)
我可以选择"摄影师的名字"
In [172]: metaData = driver.find_element_by_class_name('metadata')
In [173]: metaData.find_element_by_xpath('strong').text
Out[173]: u"Photographer's Name:"
Run Code Online (Sandbox Code Playgroud)
我正在尝试选择标记后的文本部分(示例中为"Ansel Adams").我假设我可以使用以下兄弟选择器,但我收到以下错误:
In [174]: metaData.find_element_by_xpath('strong/following-sibling::text()')
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (328, 0))
... [NOTE: Omitted the traceback for brevity] ...
InvalidSelectiorException: Message: u'The given selector strong/following-sibling::text() is either invalid or does not result in a WebElement. The following error occurred:\n[InvalidSelectorError] …Run Code Online (Sandbox Code Playgroud) 我有两个文件,都在同一个项目中(Web抓取框架的一部分).File1处理由File2生成的项目.在File2中,我有一个函数可以打印出有关进程的一些基本统计信息(生成了多少项的计数等).我在File1中有计数,我想用File1的统计数据打印但不确定如何做到这一点.看一下示例代码.
文件1:
class Class1(object):
def __init__(self):
self.stats = counter("name") #This is the instance that I'd like to use in File2
self.stats.count = 10
class counter:
def __init__(self, name):
self.name = name
self.count = 0
def __string__(self):
message = self.name + self.count
return message
Run Code Online (Sandbox Code Playgroud)
文件2 :(这是我想做的)
from project import file1 # this import returns no error
def stats():
print file1.Class1.stats # This is where I'm trying to get the instance created in Class1 of File2.
#print file1.Class1.stats.count # Furthermore, it would …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Github Actions 工作流程中部署我的 Fargate 服务(使用 ARM64 Graviton 处理器)。但是,当我的 Docker 尝试构建映像时,RUN语句失败:
Warning: The requested image's platform (linux/arm64/v8) does not match the detected host platform (linux/amd64) and no specific platform was requested
---> Running in 025f2d97f759
exec /bin/sh: exec format error
Removing intermediate container f2c3858b0496
The command '/bin/sh -c apt-get update' returned a non-zero code: 1
---> 02ceb19d6208
[66%] fail: docker build --tag cdkasset-7e1b96b9aea331ad2efd7e6fbf6f075033eca830469ea4ab8d57bf4a8eeb86cd --file Dockerfile --platform linux/arm64 . exited with error code 1: The command '/bin/sh -c apt-get …Run Code Online (Sandbox Code Playgroud) 尝试在Ubuntu 11.10上安装PostGIS 2.0.0.我基本上遵循了这里的OSGeo指令:http://trac.osgeo.org/postgis/wiki/UsersWikiPostGIS20Ubuntu1110src.我建立了GEOS 3.3.3.如果我输入geos-config --version终端,我会被退回3.3.3.
我可以跑./configure,make没有问题. ./configure以..结束:
PostGIS is now configured for x86_64-unknown-linux-gnu
-------------- Compiler Info -------------
C compiler: gcc -g -O2
C++ compiler: g++ -g -O2
-------------- Dependencies --------------
GEOS config: /usr/local/bin/geos-config
GEOS version: 3.3.3
GDAL config: /usr/local/bin/gdal-config
GDAL version: 1.9.0
PostgreSQL config: /usr/bin/pg_config
PostgreSQL version: PostgreSQL 9.1.3
PROJ4 version: 47
Libxml2 config: /usr/bin/xml2-config
Libxml2 version: 2.7.8
JSON-C support: no
PostGIS debug level: 0
Perl: /usr/bin/perl …Run Code Online (Sandbox Code Playgroud) 模型,带抽象基类:
class MapObject(models.Model):
start_date = models.DateTimeField(default= datetime.strptime('1940-09-01T00:00:00', '%Y-%m-%dT%H:%M:%S'))
end_date = models.DateTimeField(default= datetime.strptime('1941-07-01T00:00:00', '%Y-%m-%dT%H:%M:%S'))
description = models.TextField(blank=True)
location = models.PointField()
objects = models.GeoManager()
user = models.ForeignKey(User)
created = models.DateTimeField(auto_now_add = True)
last_modified = models.DateTimeField(auto_now = True)
source = models.ForeignKey(Source)
address= models.TextField(blank=True, null=True)
address_road = models.TextField(blank=True, null=True)
class Meta:
abstract = True
class Bomb(MapObject, BombExtraManager):
#Bomb Attributes
type = models.CharField(choices= Type_CHOICES, max_length=10)
night_bombing = models.BooleanField(blank=True)
map_sheet = models.ForeignKey(MapSheet, blank=True, null=True)
def __unicode__(self):
return self.type
Run Code Online (Sandbox Code Playgroud)
现在,我希望使用Django ORM获得与此查询相同的结果:
Select date_part('day',"start_date") as "day", date_part('hour',"start_date") as …Run Code Online (Sandbox Code Playgroud)