Comments (10)
passthru takes an optional second parameter to capture the status result code (0-255).
The Terminus Build Tools plugin defines a convenience wrapper for passthru:
/**
* Call passthru; throw an exception on failure.
*
* @param string $command
*/
protected function passthru($command)
{
$result = 0;
$this->log()->notice("Running {cmd}", ['cmd' => $command]);
passthru($command, $result);
if ($result != 0) {
throw new TerminusException('Command `{command}` failed with exit code {status}', ['command' => $loggedCommand, 'status' => $result]);
}
}
I simplified it slightly for comprehensibility. We could provide some utility traits in the examples so that users who copy them verbatim would get correct behavior. It would be desirable if the examples were correct, even though it is not entirely clear whether they were intended to ever be anything more than starting points for development.
from quicksilver-examples.
I think that a good example:
- Is clear
- Is correct
- Has no dependencies (works standalone)
I therefore think that duplicating a short passthru utility in every example is fine.
from quicksilver-examples.
If we start having a large number of helper functions / classes in each example, though, then the "is clear" part starts to become degraded. If this happens, then we should consider the best way to introduce dependencies to reduce duplication.
from quicksilver-examples.
from quicksilver-examples.
Hi @marfillaster thank you for opening this issue! I'm sorry, I'm not sure I understand the issue here - could you walk me through the false positive error that occurs?
My understanding of the passthru
command was that we don't need to worry about the return value because we're just outputting to the browser.
from quicksilver-examples.
from quicksilver-examples.
Oh I see, thank you for the explanation and the examples - that's very helpful.
I'm going to go ahead and see if I can test your recommended solution with some of these examples and then we can open a PR to get these usages updated.
cc @populist who's been working on maintaining this repo with me in case you have thoughts on the passthru
command updates - I'm digging into this for the first time :)
from quicksilver-examples.
I definitely like the idea of providing examples that provide better error handling to folks who use them. Did a quick test of the passthru() method with our config_import script and can see errors surfaced in the output:
Fatal error: Command "drush config-import-error -y" exit status: 1 in /srv/bindings/c79d510f61594387817f1360626c86dd/code/private/scripts/drush_config_import/drush_config_import.php on line 7
from quicksilver-examples.
Thank you for looking into this and testing @populist!
I've been reading up on pass_thru()
and wondering if it's being used incorrectly for these examples. Documentation indicates that pass_thru()
is recommended for executing commands in which the returned output is something binary.
If we're having issues catching non-zero/non-binary exit codes, perhaps we shouldn't be using pass_thur()
to begin with. If so, adding an error catch statement feels like treating the symptom, not the cause.
Instead, I'd like to replace the command with something else that supports nonzero output instead of adding a layer to the existing code - maybe with the system( )
command
Let me know what you think :)
from quicksilver-examples.
I received an update from Ken that the 500 timeout error is actually a client error and that engineering is looking into it.
Thanks for the example @greg-1-anderson - I like the idea of the convenience wrapper or a utility trait that expands on passthru()
and allows us to catch errors - but how do we ship that with the examples? Duplicating this in every example feels redundant. @populist and I have been looking into maintaining this repo and making it easier to use so this feels relevant.
from quicksilver-examples.
Related Issues (20)
- Can sync_code detect a git tag creation? HOT 1
- URL Checker value always 1 HOT 1
- Slack Notifications don't work with multidev HOT 2
- undefined variable: deploy tag in new_relic_deploy.php script HOT 2
- Example of Programmatic Backup?
- New Relic API v2 HOT 3
- Example wanted: Post Solr schema after creating new multidev env with Drupal HOT 5
- [docs] Timeout 60 seconds
- Reducing secrets.json credential overlap or confusion
- Add curl timeout to New Relic API request, to prevent hung php worker / failed deploy workflow
- Edit readme to make it clearer
- Remove SpotBot VRT script
- Is it possible to setup database version ? HOT 2
- diffy.website integration is unnecessarily tedious HOT 1
- autopilot_vrt example
- Slack integration - correct script location
- Script path and 404 while running your Quicksilver operation HOT 2
- Copying example.pantheon.yml file may cause some error
- GitHub Action from GitHub App example
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from quicksilver-examples.