zulip | Zulip server and web application | Chat library
kandi X-RAY | zulip Summary
Support
Quality
Security
License
Reuse
- Apply an event to a user profile .
- Update a message .
- Fetch initial state data .
- Imports a realm dump .
- Register a new account .
- Update the realm .
- Perform ad - hoc queries .
- Gets messages backends .
- Sends the given list of send messages .
- Get recipient info .
zulip Key Features
zulip Examples and Code Snippets
# build the project # will output some error ignore it ./build-project # to run tests ./run-tests
Trending Discussions on zulip
Trending Discussions on zulip
QUESTION
I try to execute this script directly via curl, but this fails:
curl -sSL https://raw.githubusercontent.com/guettli/fix-CVE-2020-15228/main/fix_CVE_2020_15228.py | python3 .
/srv/zulip-py3-venv/bin/python3: can't find '__main__' module in '.'
(23) Failed writing body
What's wrong?
It works if I do it in two step (download the file, then execute it)
ANSWER
Answered 2020-Nov-13 at 16:34There is a -
missing.
This works:
curl -sSL https://.../foo.py | python3 - .
QUESTION
Is there any way to run name resolution on an arbitrary expression without running it? e.g. I would like to take an expression such as
quote
x = 1
y = 2*x + 1
z = x^2 - 1
f(x) = 2*x + 1
end
and be told that the names defined in the scope of this block are x, y, z, f
and the names *, +, ^, -
are pulled in from outside the scope of this block. Bonus points if it can tell me that there's a sub-scope defined in the body of f
which creates it's own name x
and pulls in +
from an enclosing scope.
This question appeared in the Julia Zulip community
ANSWER
Answered 2020-Oct-07 at 22:03Thanks to Takafumi for showing me how to solve this on Zulip
We can get a list of locally defined names in the outermost scope of a julia expression like so:
ex = quote
x = 1
y = 2*x + 1
z = x^2 - 1
f(x) = 2*x + 1
end
using JuliaVariables, MLStyle
function get_locals(ex::Expr)
vars = (solve_from_local ∘ simplify_ex)(ex).args[1].bounds
map(x -> x.name, vars)
end
julia> get_locals(ex)
4-element Array{Symbol,1}:
:f
:y
:z
:x
and we can get the symbols pulled in from outside the scope like this:
_get_outers(_) = Symbol[]
_get_outers(x::Var) = x.is_global ? [x.name] : Symbol[]
function _get_outers(ex::Expr)
@match ex begin
Expr(:(=), _, rhs) => _get_outers(rhs)
Expr(:tuple, _..., Expr(:(=), _, rhs)) => _get_outers(rhs)
Expr(_, args...) => mapreduce(_get_outers, vcat, args)
end
end
get_outers(ex) = (unique! ∘ _get_outers ∘ solve_from_local ∘ simplify_ex)(ex)
julia> get_outers(ex)
6-element Array{Symbol,1}:
:+
:*
:-
:^
QUESTION
I am trying to figure how you are supposed to gracefully fail during application startup in quarkus.
- i tried adding this to the application startup code. This is right now not being called if i run one of the unit tests. It is only called if i start the application directly. I was hoping to return a non zero value as oppose to throwing an exception. This might be the recomended approach. I am not sure.
public class MyApp implements QuarkusApplication {
@Override
public int run(String... args) throws Exception {
System.out.println("Do startup logic here");
Quarkus.waitForExit();
return 0;
}
- i also tried raising an exception from the onStart lifecycle event. But it seems quarkus kept continuing its execution
void onStart(@Observes StartupEvent ev) {
LOGGER.info("The application is starting...");
}
void onStop(@Observes ShutdownEvent ev) {
LOGGER.info("The application is stopping...");
}
I am not sure if this is a feature request a bug or i am missing something and this is normal behaviour.
Edit1: Just to be clear:
@Startup
@ApplicationScoped
public class StarterBean {
private static final Logger LOGGER = Logger.getLogger("");
public StarterBean() {
throw new RuntimeException("failed misrably");
}
}
when i run with "./gradlew quarkusDev` i see the exception in the console but the application never exists. I was thinking it should. It does exit during unit tests and properly fails. I tried moving the exception in the onStart and that did not help as well. I also tried combinations of having each of Startup,ApplicationScoped or both
Edit2:
I tested it by building the uber jar and running that. Raising the exception does quit the application. Also as one can imagine the application also exits when running in the docker container. I am puzzled why the gradle task never exist. So to that end i think i will accept the answer . Thank you so much for your help !
ANSWER
Answered 2020-Jul-01 at 21:21I'm not sure there's a nice answer here that fulfils all requirements (happy to be corrected if I'm wrong.) Not sure exactly what you're trying to achieve, but a few options which may be worth exploring:
Quarkus.asyncExit(code)
in yourrun()
method will allow you to exit gracefully, but this won't be called by unit tests.- You can initialise a bean at startup (annotate it with
@Startup
) that throws an exception in its constructor, but that isn't particularly elegant and won't give you control of the status code. It does however seem to return -1, so it does fulfil your criteria of a non-zero exit code at least. (SadlyQuarkus.asyncExit(code)
doesn't seem to work for unit tests, even though it's executed in the bean initialisation before the test stars.) - As above, but you can call
System.exit()
in the bean constructor. This gives you control over the exit code, but is the least clean approach, it simply yanks the VM away without any graceful opportunity for cleanup.
EDIT: Just seen this from the zulipchat thread which adds some necessary context:
I need to be able to bail out during startup if i see certain conditions (for example missing env variables or whatever) how am i supposed to do it ?
In this case, I would probably declare a @Startup
bean (or beans) to initialise based on these environment variables, and make sure the constructors of those beans throw meaningful exceptions if the conditions aren't right (missing env variables, corrupt env variables, etc.) That has a few advantages:
- You can separate your appropriate startup checks into distinct beans, enforcing separation of responsibilities;
- You have meaningful information to analyse & action in logs;
- You meaningfully halt with a non-zero exit code if things are wrong as a result of throwing that exception, allowing a container healthcheck system to report that a node has died badly.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install zulip
Contributing code. Check out our guide for new contributors to get started. Zulip prides itself on maintaining a clean and well-tested codebase, and a stock of hundreds of beginner-friendly issues.
Contributing non-code. Report an issue, translate Zulip into your language, write for the Zulip blog, or give us feedback. We would love to hear from you, even if you're just trying the product out.
Supporting Zulip. Advocate for your organization to use Zulip, become a sponsor, write a review in the mobile app stores, or upvote Zulip on product comparison sites.
Checking Zulip out. The best way to see Zulip in action is to drop by the Zulip community server. We also recommend reading Zulip for open source, Zulip for companies, or Zulip for communities.
Running a Zulip server. Use a preconfigured DigitalOcean droplet, install Zulip directly, or use Zulip's experimental Docker image. Commercial support is available; see https://zulip.com/plans for details.
Using Zulip without setting up a server. https://zulip.com offers free and commercial hosting, including providing our paid plan for free to fellow open source projects.
Participating in outreach programs like Google Summer of Code.
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page