druid | Apache Druid : a high performance
kandi X-RAY | druid Summary
Support
Quality
Security
License
Reuse
- Runs the internal task .
- Constructs and initializes a Jetty Server .
- Translates an expression into a leaf filter .
- Scan and aggregate the data for the specified dimensions .
- Intersection of two sets .
- Generates a proxy for a given hostname .
- Process an announcement .
- Merge and push a sink .
- Make a join cursor from a joinable joinable .
- Generate and publish segments .
druid Key Features
druid Examples and Code Snippets
Trending Discussions on druid
Trending Discussions on druid
QUESTION
I'm learning JavaWeb and deploying local tomcat9 in idea. An exception occurred when I tried to connect to the database by reading the properties file. It should be that my properties file was not found.
I tried to change the file path but it didn't work. What should I do?
This is my method to connect to the database and message
public class JDBCUtil {
private static DataSource druidSource;
static {
Properties props = new Properties();
InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("production/begin/druid.properties");
try {
props.load(is);
druidSource = DruidDataSourceFactory.createDataSource(props);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Connection getConnection() throws SQLException {
return druidSource.getConnection();
}
}
java.lang.NullPointerException: inStream parameter is null
at java.base/java.util.Objects.requireNonNull(Objects.java:233)
at java.base/java.util.Properties.load(Properties.java:407)
at DAO.util.JDBCUtil.(JDBCUtil.java:24)
at servlets.AddServlet.doPost(AddServlet.java:39)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:681)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:764)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:197)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:541)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:135)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:687)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:360)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:399)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:890)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1743)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at org.apache.tomcat.util.threads.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1191)
at org.apache.tomcat.util.threads.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:659)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.base/java.lang.Thread.run(Thread.java:831)
This is my directory
Operating environment:MacOS12, idea2021.3.3, tomcat9.0.62, Java16.0.1
ANSWER
Answered 2022-Apr-02 at 16:04This problem has been solved.Thank for rehnoj's help.
The answer in Different behavior of ClassLoader.getSystemClassLoader().getResource() in servlet container and test environment.
The correct code
public class JDBCUtil {
private static DataSource druidSource;
static {
Properties props = new Properties();
InputStream is = JDBCUtil.class.getClassLoader().getResourceAsStream("druid.properties");
try {
props.load(is);
druidSource = DruidDataSourceFactory.createDataSource(props);
} catch (Exception e) {
e.printStackTrace();
}
}
public static Connection getConnection() throws SQLException {
return druidSource.getConnection();
}
}
QUESTION
I wanted to get Strings/ints of several Items out of a JSON Array, but I don't really know how I can achieve that
static void Main(string[] args)
{
Console.WriteLine(jsonRequest("Râsu", "Aegwynn", "mythic_plus_best_runs").SelectToken("mythic_plus_best_runs"));
Console.ReadKey();
}
public static dynamic jsonRequest(String playerName, String realmName, String requestField)
{
String json = new WebClient().DownloadString("https://raider.io/api/v1/characters/profile?region=eu&realm=" + realmName + "&name=" + playerName + "&fields=" + requestField);
dynamic liste = JsonConvert.DeserializeObject(json);
return liste;
}
using Newtonsoft.Json;
using System;
using System.Net;
got used in this Project
I wanted to get the "dungeon" and the "key_level" string / int out of it for every single item, but when I did
Console.WriteLine(jsonRequest("Râsu", "Aegwynn", "mythic_plus_best_runs").SelectToken("mythic_plus_best_runs.dungeon"));
it just throws
{
"name": "Râsu",
"race": "Worgen",
"class": "Druid",
"active_spec_name": "Balance",
"active_spec_role": "DPS",
"gender": "male",
"faction": "alliance",
"achievement_points": 15570,
"honorable_kills": 0,
"thumbnail_url": "https://render-eu.worldofwarcraft.com/character/aegwynn/240/202932208-avatar.jpg?alt=wow/static/images/2d/avatar/22-0.jpg",
"region": "eu",
"realm": "Aegwynn",
"last_crawled_at": "2022-03-22T08:24:35.000Z",
"profile_url": "https://raider.io/characters/eu/aegwynn/Râsu",
"profile_banner": "alliancebanner1",
"mythic_plus_best_runs": [
{
"dungeon": "De Other Side",
"short_name": "DOS",
"mythic_level": 18,
"completed_at": "2022-03-17T18:19:03.000Z",
"clear_time_ms": 2274234,
"par_time_ms": 2580999,
"num_keystone_upgrades": 1,
"map_challenge_mode_id": 377,
"zone_id": 13309,
"score": 141.5,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2154109-18-de-other-side"
},
{
"dungeon": "Spires of Ascension",
"short_name": "SOA",
"mythic_level": 18,
"completed_at": "2022-03-19T19:23:45.000Z",
"clear_time_ms": 2483104,
"par_time_ms": 2340999,
"num_keystone_upgrades": 0,
"map_challenge_mode_id": 381,
"zone_id": 12837,
"score": 134.2,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2540683-18-spires-of-ascension"
},
{
"dungeon": "Plaguefall",
"short_name": "PF",
"mythic_level": 16,
"completed_at": "2022-03-17T17:31:37.000Z",
"clear_time_ms": 1641342,
"par_time_ms": 2280999,
"num_keystone_upgrades": 2,
"map_challenge_mode_id": 379,
"zone_id": 13228,
"score": 133.5,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2149124-16-plaguefall"
},
{
"dungeon": "Theater of Pain",
"short_name": "TOP",
"mythic_level": 16,
"completed_at": "2022-03-19T21:57:57.000Z",
"clear_time_ms": 2127992,
"par_time_ms": 2280999,
"num_keystone_upgrades": 1,
"map_challenge_mode_id": 382,
"zone_id": 12841,
"score": 130.8,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2544779-16-theater-of-pain"
},
{
"dungeon": "Halls of Atonement",
"short_name": "HOA",
"mythic_level": 15,
"completed_at": "2022-03-19T20:28:03.000Z",
"clear_time_ms": 1359135,
"par_time_ms": 1920999,
"num_keystone_upgrades": 2,
"map_challenge_mode_id": 378,
"zone_id": 12831,
"score": 128.7,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2544778-15-halls-of-atonement"
},
{
"dungeon": "Sanguine Depths",
"short_name": "SD",
"mythic_level": 15,
"completed_at": "2022-03-19T21:13:44.000Z",
"clear_time_ms": 1827333,
"par_time_ms": 2460999,
"num_keystone_upgrades": 2,
"map_challenge_mode_id": 380,
"zone_id": 12842,
"score": 128.2,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2544767-15-sanguine-depths"
},
{
"dungeon": "The Necrotic Wake",
"short_name": "NW",
"mythic_level": 15,
"completed_at": "2022-03-17T16:31:27.000Z",
"clear_time_ms": 1649375,
"par_time_ms": 2160999,
"num_keystone_upgrades": 2,
"map_challenge_mode_id": 376,
"zone_id": 12916,
"score": 128,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2142513-15-the-necrotic-wake"
},
{
"dungeon": "Mists of Tirna Scithe",
"short_name": "MISTS",
"mythic_level": 17,
"completed_at": "2022-03-09T15:25:20.000Z",
"clear_time_ms": 2198966,
"par_time_ms": 1800999,
"num_keystone_upgrades": 0,
"map_challenge_mode_id": 375,
"zone_id": 13334,
"score": 127.2,
"affixes": [
{
"id": 10,
"name": "Fortified",
"description": "Non-boss enemies have 20% more health and inflict up to 30% increased damage.",
"icon": "ability_toughness",
"wowhead_url": "https://wowhead.com/affix=10"
},
{
"id": 11,
"name": "Bursting",
"description": "When slain, non-boss enemies explode, causing all players to suffer damage over 4 sec. This effect stacks.",
"icon": "ability_ironmaidens_whirlofblood",
"wowhead_url": "https://wowhead.com/affix=11"
},
{
"id": 124,
"name": "Storming",
"description": "While in combat, enemies periodically summon damaging whirlwinds.",
"icon": "spell_nature_cyclone",
"wowhead_url": "https://wowhead.com/affix=124"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/956881-17-mists-of-tirna-scithe"
},
{
"dungeon": "Tazavesh: So'leah's Gambit",
"short_name": "GMBT",
"mythic_level": 15,
"completed_at": "2022-03-20T18:00:05.000Z",
"clear_time_ms": 1529610,
"par_time_ms": 1800999,
"num_keystone_upgrades": 1,
"map_challenge_mode_id": 392,
"zone_id": 1000001,
"score": 126.9,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2626552-15-tazavesh-soleahs-gambit"
},
{
"dungeon": "Tazavesh: Streets of Wonder",
"short_name": "STRT",
"mythic_level": 14,
"completed_at": "2022-03-20T16:46:08.000Z",
"clear_time_ms": 1887336,
"par_time_ms": 2340999,
"num_keystone_upgrades": 1,
"map_challenge_mode_id": 391,
"zone_id": 1000000,
"score": 122.4,
"affixes": [
{
"id": 9,
"name": "Tyrannical",
"description": "Bosses have 30% more health. Bosses and their minions inflict up to 15% increased damage.",
"icon": "achievement_boss_archaedas",
"wowhead_url": "https://wowhead.com/affix=9"
},
{
"id": 6,
"name": "Raging",
"description": "Non-boss enemies enrage at 30% health remaining, dealing 50% increased damage until defeated.",
"icon": "ability_warrior_focusedrage",
"wowhead_url": "https://wowhead.com/affix=6"
},
{
"id": 3,
"name": "Volcanic",
"description": "While in combat, enemies periodically cause gouts of flame to erupt beneath the feet of distant players.",
"icon": "spell_shaman_lavasurge",
"wowhead_url": "https://wowhead.com/affix=3"
},
{
"id": 130,
"name": "Encrypted",
"description": "Enemies throughout the dungeon possess relics of the First Ones. Destroy the relics to summon the First Ones' Automa and gain powerful bonuses, based on the order in which they were destroyed.",
"icon": "spell_progenitor_orb",
"wowhead_url": "https://wowhead.com/affix=130"
}
],
"url": "https://raider.io/mythic-plus-runs/season-sl-3/2650220-14-tazavesh-streets-of-wonder"
}
]
}
That's the Json File where i need the values from
ANSWER
Answered 2022-Mar-23 at 01:04The value of the key "mythic_plus_best_runs" is an array.
So, you must loop over it to get all "dungeon" values.
var result = jsonRequest("Râsu", "Aegwynn", "mythic_plus_best_runs");
foreach (var item in result["mythic_plus_best_runs"])
{
Console.WriteLine(item["dungeon"]);
}
QUESTION
I am trying to download image using another thread and to send downloaded bytes in ImageBuf object to main thread using Druid command system. The code I am using is:
let event_sink = ctx.get_external_handle();
thread::spawn(move || {
let content_bytes = download_bytes("https://media.istockphoto.com/photos/generic-drug-box-picture-id1054301628");
let raw_content_bytes : &[u8] = content_bytes.as_ref();
let image_buffer = ImageBuf::from_data(raw_content_bytes).expect("Failed to store bytes into image buffer");
event_sink.submit_command(UPDATE_IMAGE_COMMAND, image_buffer, Target::from(image_widget_id));
});
The last line throws an error message saying:
the trait bound `Box<()>: From` is not satisfied
the following implementations were found:
<(dyn StdError + 'a)> as From>
<(dyn StdError + 'static)> as From<&str>>
<(dyn StdError + 'static)> as From<'a, str>>>
<(dyn StdError + 'static)> as From>
and 25 others
required because of the requirements on the impl of `Into<()>>` for `ImageBuf`
I am not sure what this really means, I have been looking through examples and tried wrapping image_buffer into box but none of it have helped so far.
Do note that in Druid examples there is one example(blocking_function) that sends raw number(u32) as payload, but when I try to put hardcoded number instead of image_buffer in my code, I still get the same error message.
ANSWER
Answered 2022-Feb-18 at 11:11TL;DR
Add generic argument: pub(crate) const UPDATE_IMAGE_COMMAND: Selector = Selector::new("update_image");
Thanks to comment from @Caesar i applied .submit_command::(…)
and figured out that druid Selector
have generic type on them which determines what kind of payload can be sent with the finally generated Command
. Default type for Selector
is so the fix for my problem was just to add
ImageBuf
as generic argument for selector as shown in the code snippet above
QUESTION
My maven settings.xml is as follows. As you can see, there is no http repository url. All repository url is started with https.
mirror
central,jcenter,!rdc-releases,!rdc-snapshots
mirror
https://maven.aliyun.com/nexus/content/groups/public
rdc-releases
myUserName
myPwd
rdc-snapshots
myUserName
myPwd
rdc
rdc-releases::default::https://packages.aliyun.com/maven/repository/2012878-release-sX3W6A/
rdc-snapshots::default::https://packages.aliyun.com/maven/repository/2012878-snapshot-wXHWRP/
central
https://maven.aliyun.com/nexus/content/groups/public
true
false
snapshots
https://maven.aliyun.com/nexus/content/groups/public
false
true
rdc-releases
https://packages.aliyun.com/maven/repository/2012878-release-sX3W6A/
true
false
rdc-snapshots
https://packages.aliyun.com/maven/repository/2012878-snapshot-wXHWRP/
false
true
rdc
When I execute gradle build, it says I use insecure protocol. In fact, I never use http protocol in my maven settings.xml. We can see that all repository url is started with 'https://'. Can any one give me some advice ?
## Exception is
> Task :buildSrc:compileJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':buildSrc:compileJava'.
> Could not resolve all dependencies for configuration ':buildSrc:compileClasspath'.
> Using insecure protocols with repositories, without explicit opt-in, is unsupported. Switch Maven repository 'maven(http://maven.aliyun.com/nexus/content/groups/public)' to redirect to a secure protocol (like HTTPS) or allow insecure protocols. See https://docs.gradle.org/7.4/dsl/org.gradle.api.artifacts.repositories.UrlArtifactRepository.html#org.gradle.api.artifacts.repositories.UrlArtifactRepository:allowInsecureProtocol for more details.
My gradle version is 7.4 and part of the build.gradle is as follows. It is a multi module project. I give one module gradle setting as an example.
settings.gradle
/*
* This file was generated by the Gradle 'init' task.
*/
rootProject.name = 'clougence-schema-parent'
include(':clougence-utils')
build.gradle of module clougence-utils
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'com.clougence.java-conventions'
}
description = 'clougence-utils'
groovy scrips
/*
* This file was generated by the Gradle 'init' task.
*/
plugins {
id 'java-library'
id 'maven-publish'
}
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compileOnly 'org.slf4j:slf4j-api:1.7.30'
compileOnly 'org.projectlombok:lombok:1.18.20'
annotationProcessor 'org.projectlombok:lombok:1.18.20'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.20'
testCompileOnly 'org.projectlombok:lombok:1.18.20'
testImplementation 'com.alibaba:druid:1.2.6'
testImplementation 'junit:junit:4.12'
testImplementation 'net.hasor:hasor-db:4.3.0'
testImplementation 'com.alibaba:druid:1.2.6'
}
group = 'com.clougence'
version = '1.0.12-SNAPSHOT'
java.sourceCompatibility = JavaVersion.VERSION_1_8
publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
ANSWER
Answered 2022-Feb-18 at 06:54I find answer myself. I used to config ~/.gradle/init.gradle and set a http url which force gradle to use that insecure repository
QUESTION
I am using Druid as datasource for my grafana. I want to ignore the first and last data points from the druid query result(like trimming the edges). I am thinking of modifying the timestamp passed to druid query from the timepicker. But I cannot find a way to modify the timestamp choosen from the timepicker in grafana. Is there any other way to ignore the first and last data points? Sample query sent by grafana
"__time" >= TIME_PARSE('2022-02-13T07:32:46.055Z') AND "__time" <= TIME_PARSE('2022-02-13T10:32:46.055Z')
ANSWER
Answered 2022-Feb-14 at 13:24I don't know about Druid specifically, but I can answer your question and tell you that it is possible to modify the time range selected by the time picker.
That is by using the built in variables $__from and $__to. Those give you begin and respectively end of the selected time range in UNIX milliseconds. You can then add/subtract milliseconds to/from those to modify the time range used in your query (e.g. in the WHERE clause).
QUESTION
I have gone through following Druid Scan query documentation https://druid.apache.org/docs/0.20.0/querying/scan-query.html . I didn't understand the part when it says. "note that if the underlying datasource is modified in between page fetches in ways that affect overall query results, then the different pages will not necessarily align with each other."
In my case data is added to Druid in real time which means suppose I queried for last one hour data(4-5PM), it might possible that earlier we had 40 records for that query but during the query we received 10 new records. My assumption is that all new records should get added post 40th record and it should not impact the current running paging offset. Please help me how realtime ingestion of data can impact the Druid pagination and what could be the possible fix for that.
offset : Together, "limit" and "offset" can be used to implement pagination. However, note that if the underlying datasource is modified in between page fetches in ways that affect overall query results, then the different pages will not necessarily align with each other.
ANSWER
Answered 2022-Jan-28 at 20:32The docs describe that the offset/limit are application side values. From the database perspective, it is running the whole query again with every request and just returning the rows between offset
and offset + limit
.
So, if ordered by __time desc
, new rows will appear at the top of the results and therefore shift the content of the pagination. If sorted __time asc
, and no out of time order rows are ingested between calls, then the pagination should be constant and new rows appear at the end.
Also remember that it is a good practice to limit the overall timeframe that you are querying.
QUESTION
I am trying to automate druid batch ingestion using Airflow. My data pipeline creates EMR cluster on demand and shut it down once druid indexing is completed. But for druid we need to have Hadoop configurations in druid server folder ref. This is blocking me from dynamic EMR clusters. Can we override Hadoop connection details in Job configuration or is there a way to support multiple indexing jobs to use different EMR clusters ?
ANSWER
Answered 2022-Jan-20 at 22:21In researching how this might be done, I found hadoopDependencyCoordinates
property here: https://druid.apache.org/docs/0.22.1/ingestion/hadoop.html#task-syntax
which seems relevant.
QUESTION
I'm developing a web scraper to mine data from the Solis Pro platform (Ginlong), but I'm having problems getting the asynchronous data from the plants registered by the user. I'm using Selenium + bs4 and the following has happened. The url is https://m.ginlong.com/pro/epc/plantview/view/doAsyncPlantList.json. I send a payload and in theory I should receive the data, but I am either receiving an error or only part of the data (only {status: 1}).
url = 'https://m.ginlong.com/'
chrome_options = Options()
chrome_options.add_argument("--headless")
webdriver = Chrome(ChromeDriverManager().install(), options=chrome_options)
webdriver.get(url+'login.html')
webdriver.find_element(By.XPATH, '//button[@ng-click="typeChange()"]').click()
webdriver.find_element_by_name("username").send_keys(username)
webdriver.find_element_by_name("password").send_keys(password)
#webdriver.find_element(By.XPATH, '//button[@class="close close-ico tra-fast"]').click()
webdriver.find_element(By.XPATH, '//button[@id="login"]').click()
soup = BeautifulSoup(webdriver.page_source, 'lxml')
headers = {
"content-type": "application/x-www-form-urlencoded",
"accept": "application/json",
"user-agent": "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Mobile Safari/537.36"
}
postData = {
"plantArray": [{"plantId":1033610,"timezoneId":24,"updateTime":"2022-01-18"},{"plantId":1028383,"timezoneId":24,"updateTime":"2022-01-18"}]
}
response = webdriver.request('POST', url+'pro/epc/plantview/view/doAsyncPlantList.json', headers=headers, data=postData)
if response.status_code != 200:
raise RuntimeError("A requisição falhou: %s", response)
data = BeautifulSoup(response.text, 'html.parser')
print(data.text)
The error that I'm getting
Exception: Unrecognized token 'plantId': was expecting ('true', 'false' or 'null')
at [Source: plantId,timezoneId,updateTime,plantId,timezoneId,updateTime; line: 1, column: 8]
com.fasterxml.jackson.core.JsonParseException: Unrecognized token 'plantId': was expecting ('true', 'false' or 'null')
at [Source: plantId,timezoneId,updateTime,plantId,timezoneId,updateTime; line: 1, column: 8]
at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702)
at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._reportInvalidToken(ReaderBasedJsonParser.java:2836)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser._handleOddValue(ReaderBasedJsonParser.java:1899)
at com.fasterxml.jackson.core.json.ReaderBasedJsonParser.nextToken(ReaderBasedJsonParser.java:749)
at com.fasterxml.jackson.databind.ObjectMapper._initForReading(ObjectMapper.java:3847)
at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:3792)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:2835)
at com.igen.solarman.controller.epc.PlantViewController.doAsyncPlantList(PlantViewController.java:345)
at com.igen.solarman.controller.epc.PlantViewController$$FastClassBySpringCGLIB$$70060edf.invoke()
at org.springframework.cglib.proxy.MethodProxy.invoke(MethodProxy.java:204)
at org.springframework.aop.framework.CglibAopProxy$CglibMethodInvocation.invokeJoinpoint(CglibAopProxy.java:720)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:157)
at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
at org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:655)
at com.igen.solarman.controller.epc.PlantViewController$$EnhancerBySpringCGLIB$$b39c8e9a.doAsyncPlantList()
at sun.reflect.GeneratedMethodAccessor1121.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:221)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:136)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:114)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:827)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:738)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:872)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:650)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at com.alibaba.druid.support.http.WebStatFilter.doFilter(WebStatFilter.java:123)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.tuckey.web.filters.urlrewrite.RuleChain.handleRewrite(RuleChain.java:176)
at org.tuckey.web.filters.urlrewrite.RuleChain.doRules(RuleChain.java:145)
at org.tuckey.web.filters.urlrewrite.UrlRewriter.processRequest(UrlRewriter.java:92)
at org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.doFilter(UrlRewriteFilter.java:394)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:61)
at org.apache.shiro.web.servlet.AdviceFilter.executeChain(AdviceFilter.java:108)
at org.apache.shiro.web.servlet.AdviceFilter.doFilterInternal(AdviceFilter.java:137)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.apache.shiro.web.servlet.ProxiedFilterChain.doFilter(ProxiedFilterChain.java:66)
at org.apache.shiro.web.servlet.AbstractShiroFilter.executeChain(AbstractShiroFilter.java:449)
at org.apache.shiro.web.servlet.AbstractShiroFilter$1.call(AbstractShiroFilter.java:365)
at org.apache.shiro.subject.support.SubjectCallable.doCall(SubjectCallable.java:90)
at org.apache.shiro.subject.support.SubjectCallable.call(SubjectCallable.java:83)
at org.apache.shiro.subject.support.DelegatingSubject.execute(DelegatingSubject.java:383)
at org.apache.shiro.web.servlet.AbstractShiroFilter.doFilterInternal(AbstractShiroFilter.java:362)
at org.apache.shiro.web.servlet.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:125)
at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:346)
at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:262)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:197)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.logging.log4j.web.Log4jServletFilter.doFilter(Log4jServletFilter.java:71)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:110)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:494)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:116)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:445)
at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1137)
at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:637)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:745)
Has anyone tried to get this data or know how I can resolve this error?
ANSWER
Answered 2022-Jan-18 at 14:00Change: response = webdriver.request('POST', url+'pro/epc/plantview/view/doAsyncPlantList.json', headers=headers, data=postData)
to this: response = webdriver.request('POST', url+'pro/epc/plantview/view/doAsyncPlantList.json', headers=headers, json=json.dumps(postData))
(remember to import json) :)
I am not sure why this works but it does, for further reading see this discussion about the difference between data=
and json=
: Difference between data and json parameters in python requests package
Also, I've managed to get it work with requests only which should speed things up, note that I've had to change my url at the end to "cpro" not "pro" like yours since I don't have a pro account: "https://m.ginlong.com/pro/epc/plantview/view/doAsyncPlantList.json"
import requests
import json
s = requests.Session()
headers = {'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.110 Safari/537.36'}
url = 'https://m.ginlong.com/login.html'
resp = s.get(url,headers=headers)
print(resp)
login_url = 'https://m.ginlong.com/cpro/login/validateLogin.json'
payload = {
'userName':'username',
'userNameDisplay':'username',
'password':'password',
'lan':'2',
'domain':'m.ginlong.com',
'userType':'C'
}
headers = {
'accept':'application/json, text/plain, */*',
'accept-encoding':'gzip, deflate, br',
'content-type':'application/x-www-form-urlencoded',
'origin':'https://m.ginlong.com',
'referer':'https://m.ginlong.com/login.html',
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
}
login = s.post(login_url,headers=headers,data=payload)
print(login)
new_plant_payload = {
'name':'new_plant_2',
'nmi':'',
'type':'2',
'gridType':'1',
'searchInput':'',
'positionAddressInput':'ChinaJiang Su ShengWu Xi ShiXin Wu QuTian An Zhi Hui Cheng A2',
'rectangle':'120.36118,31.5065;',
'lon':'120.36118',
'lat':'31.5065',
'address':'ChinaJiang Su ShengWu Xi ShiXin Wu QuTian An Zhi Hui Cheng A2',
'country':'Jiang Su Sheng',
'state':'Wu Xi Shi',
'city':'Xin Wu Qu',
'district':'Tian An Zhi Hui Cheng A2',
'countryId':'44',
'stateId':'',
'cityId':'',
'districtId':'',
'power':'5.00',
'timezoneId':'34',
'direction':'180°',
'angle':'26°',
'currencyId':'19',
'benchmarkPrice':'1.372',
'price':'0.75',
'priceNet':'1',
'subsidy':'0.372',
'subsidyYears':'20',
'subsidyLocal':'0',
'subsidyLocalYears':'0',
'subsidyCity':'0',
'subsidyCityYears':'0',
'subsidyCounty':'0',
'subsidyCountyYears':'0',
'cost':'37500.00',
'subsidyBuild':'1000',
'percent':'0%',
'interest':'0',
'years':'',
'repay':'1',
'phone':''
}
create_plant_headers = {
'accept':'application/json',
'content-type':'application/x-www-form-urlencoded',
'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36'
}
create_url = 'https://m.ginlong.com/cpro/epc/plantCreate/create/doSubmitPlant.json'
create = s.post(create_url,headers=create_plant_headers,data=new_plant_payload)
print(create)
print(create.text)
plant_id = create.json()['result']
async_url = 'https://m.ginlong.com/cpro/epc/plantview/view/doAsyncPlantList.json'
postData = {
"plantArray": [{"plantId":plant_id,"timezoneId":24,"updateTime":"2022-01-18"}]
}
post_async = s.post(async_url,json=json.dumps(postData))
print(post_async)
print(post_async.text)
QUESTION
I installed apache-druid-0.22.1 as a cluster (master, data and query nodes) and enabled “druid-google-extensions” by adding it to the array druid.extensions.loadList in common.runtime.properties. Finally I defined GOOGLE_APPLICATION_CREDENTIALS ( which has the value of service account json as defined in https://cloud.google.com/docs/authentication/production )as an environment variable of user that run the druid services. However, I got the following error when I try to ingest data from GCR buckets:
Error: Cannot construct instance of org.apache.druid.data.input.google.GoogleCloudStorageInputSource, problem: Unable to provision, see the following errors: 1) Error in custom provider, java.io.IOException: The Application Default Credentials are not available. They are available if running on Google App Engine, Google Compute Engine, or Google Cloud Shell. Otherwise, the environment variable GOOGLE_APPLICATION_CREDENTIALS must be defined pointing to a file defining the credentials. See https://developers.google.com/accounts/docs/application-default-credentials for more information. at org.apache.druid.common.gcp.GcpModule.getHttpRequestInitializer(GcpModule.java:60) (via modules: com.google.inject.util.Modules$OverrideModule -> org.apache.druid.common.gcp.GcpModule) at org.apache.druid.common.gcp.GcpModule.getHttpRequestInitializer(GcpModule.java:60) (via modules: com.google.inject.util.Modules$OverrideModule -> org.apache.druid.common.gcp.GcpModule) while locating com.google.api.client.http.HttpRequestInitializer for the 3rd parameter of org.apache.druid.storage.google.GoogleStorageDruidModule.getGoogleStorage(GoogleStorageDruidModule.java:114) at org.apache.druid.storage.google.GoogleStorageDruidModule.getGoogleStorage(GoogleStorageDruidModule.java:114) (via modules: com.google.inject.util.Modules$OverrideModule -> org.apache.druid.storage.google.GoogleStorageDruidModule) while locating org.apache.druid.storage.google.GoogleStorage 1 error at [Source: (org.eclipse.jetty.server.HttpInputOverHTTP); line: 1, column: 180] (through reference chain: org.apache.druid.indexing.overlord.sampler.IndexTaskSamplerSpec["spec"]->org.apache.druid.indexing.common.task.IndexTask$IndexIngestionSpec["ioConfig"]->org.apache.druid.indexing.common.task.IndexTask$IndexIOConfig["inputSource"]) A case reported on this matter caught my attention. But I can not see any verified solution to that case. Please help me.
We want to take data from GCP to on prem Druid. We don’t want to take cluster in GCP. So that we want solve this problem.
ANSWER
Answered 2022-Jan-11 at 19:38You must define the GOOGLE_APPLICATION_CREDENTIALS
that points to a file path, and not contain the file content.
In a cluster (like Kubernetes), it's usual to mount a volume with the file in it, and to se the env var to point to that volume.
QUESTION
At the moment my code has multiple if statements that are similar (see below) and i was wondering if there was a way to make a variable or something that can change based on what comes out of the random.choice?
So if it landed on druid instead of checking if the result was barbarian then moving onto the next block of code it would just take druid from the random.choice output and change the import for a single block of code accordingly
sorry if this is worded badly, it's hard for me to convey what i mean, i can elaborate if needed
def randclass():
return random.choice(class_dict[chosenrace])
if randclass() == "Barbarian":
print(chosenrace, "Barbarian")
if fullconfirm == "yes":
from barbarianfullbuild import barbarianrandsubclass, barbarianrandbackground, barbarianskills
print(barbarianrandsubclass)
print(barbarianrandbackground)
print(barbarianskills)
if randclass() == "Druid":
print(chosenrace, "Druid")
if fullconfirm == "yes":
from druidfullbuild import druidrandsubclass, druidrandbackground, druidskills
print(druidrandsubclass)
print(druidrandbackground)
print(druidskills)
ANSWER
Answered 2022-Jan-09 at 19:06You can use python's dict as a hash-map in order to avoid those ifs:
def randclass():
return random.choice(class_dict[chosenrace])
def import_barbarian():
print(chosenrace, "Barbarian")
if fullconfirm == "yes":
from barbarianfullbuild import barbarianrandsubclass, barbarianrandbackground, barbarianskills
print(barbarianrandsubclass)
print(barbarianrandbackground)
print(barbarianskills)
def import_druid():
print(chosenrace, "Druid")
if fullconfirm == "yes":
from druidfullbuild import druidrandsubclass, druidrandbackground, druidskills
print(druidrandsubclass)
print(druidrandbackground)
print(druidskills)
import_races = {
"Barbarian": import_barbarian,
"Druid": import_druid
}
import_races[randclass()]()
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install druid
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