我正在使用function InvokeEndpoint(props:{}){
const [details, setDetails] = React.useState(
{endpoint: "testPayload", payload: '{"log":["help"]}'} );
const [invocation, setInvocation] = React.useState
<"init"|"processing"|ErrorInfo|ProcessingLogV1>("init");
let isValidEndpoint = !!details.endpoint;
let isValidPayload = true;
let payloadErrorText = "";
let parsedPayload = {};
try {
parsedPayload = JSON.parse(details.payload);
}
catch( e ) {
isValidPayload = false;
payloadErrorText = e.toString();
}
useEffect(()=>{
let mounted = true;
setInvocation("processing");
MuiServiceApi.instance.
invokeProcessingMethod(details.endpoint, parsedPayload).
then(result=> mounted && setInvocation(result)).
catch(e=> setInvocation({message: "while updating DB", problem: e}));
return ()=>{mounted = false};
}, []);
const isProcessing = invocation == "processing";
let result = undefined;
if( invocation != "init" && invocation != "processing" ){
if( isErrorInfo(invocation) ){
result = <MuiCompactErrorPanel error={invocation}/>
}
else {
result = <ul>{
invocation.log.map((it,index)=> <li key={index}>{it}</li>)
}</ul>
}
}
return <Card><CardContent> <form onSubmit={()=>{
setInvocation("processing");
MuiServiceApi.instance.
invokeProcessingMethod(details.endpoint, parsedPayload).
then(result=> {
console.log("resulted", result);
setInvocation(result);
}).
catch(e=> {
console.log("errored");
setInvocation({message: "while updating DB", problem: e});
} );
}}>
<Typography variant={"h5"}>Invoke endpoint</Typography>
<TextField id="endpointInput" label="Endpoint"
margin="normal" variant="outlined" autoComplete="on" fullWidth={true}
inputProps={{autoCapitalize:"none"}}
value={details.endpoint}
onChange={( event: ChangeEvent<HTMLInputElement> )=>{
setDetails({...details, endpoint: event.currentTarget.value});
}}
disabled={isProcessing}
error={!isValidEndpoint}
/>
<TextField id="payloadInput" label="Payload"
margin="normal" variant="outlined" autoComplete="on" fullWidth={true}
inputProps={{autoCapitalize:"none"}}
multiline={true}
value={details.payload}
onChange={( event: ChangeEvent<HTMLInputElement> )=>{
setDetails({...details, payload: event.currentTarget.value});
}}
disabled={isProcessing}
error={!isValidPayload}
helperText={payloadErrorText}
/>
<PrimaryButton type="submit" color="primary"
disabled={isProcessing || !isValidPayload || !isValidEndpoint}
>
<ButtonLabel isLoading={isProcessing}>Invoke</ButtonLabel>
</PrimaryButton>
{ result }
</form> </CardContent></Card>
}
命令构建一个dockerfile。构建时,我遇到以下错误:
docker build .
这是dockerfile:
Downloading/unpacking requests
Cannot fetch index base URL http://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement requests
No distributions at all found for requests
可能是什么问题?
答案 0 :(得分:1)
您遇到的是点子问题,而不是docker问题,您需要将pip install --index-url https://pypi.python.org/simple/ --upgrade pip
添加到您的docker文件中:
FROM jonasbonno/rpi-grovepi
RUN pip install --index-url https://pypi.python.org/simple/ --upgrade pip
RUN hash -r
RUN pip install requests
RUN git clone https://github.com/keyban/fogservice.git #update
ENTRYPOINT ["python"]
CMD ["fogservice/service.py"]
您可以在此处找到解决方案:pip connection failure: cannot fetch index base URL http://pypi.python.org/simple/