下面是我从python运行以在aws ec2实例中执行命令的代码
import boto3
ec2 = boto3.client('ssm',region_name='us-east-1',aws_access_key_id='xxxxxxxxxxxxxxx',aws_secret_access_key='xxxxxxxxx')
a = ec2.send_command(InstanceIds=ids, DocumentName='AWS-RunShellScript', Comment='abcdabcd', Parameters={"commands":["ifconfig"]})
Run Code Online (Sandbox Code Playgroud)
但它给出了以下错误
InvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation:
Run Code Online (Sandbox Code Playgroud) 我编写了一个包含多个PythonOperator的DAG
task1 = af_op.PythonOperator(task_id='Data_Extraction_Environment',
provide_context=True,
python_callable=Task1, dag=dag1)
def Task1(**kwargs):
return(kwargs['dag_run'].conf.get('file'))
Run Code Online (Sandbox Code Playgroud)
从PythonOperator我调用"Task1"方法.该方法返回一个值,该值需要传递给下一个PythonOperator.如何从"task1"变量获取值或如何获取从Task1方法返回的值?
更新 :
def Task1(**kwargs):
file_name = kwargs['dag_run'].conf.get[file]
task_instance = kwargs['task_instance']
task_instance.xcom_push(key='file', value=file_name)
return file_name
t1 = PythonOperator(task_id = 'Task1',provide_context=True,python_callable=Task1,dag=dag)
t2 = BashOperator(
task_id='Moving_bucket',
bash_command='python /home/raw.py {{ task_instance.xcom_pull(task_ids='Task1',key='file') }} ',
dag=dag,
)
t2.set_upstream(t1)
Run Code Online (Sandbox Code Playgroud) RecyclerView 下面的 TextView 未显示。整个屏幕都被 RecyclerView 占据。如果我使用 Nestedscrollview,则仅显示 TextView,但不显示 RecyclerView。请任何人提供解决方案
<LinearLayout
android:id="@+id/wrapper"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/wrapper"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)