问:
FFMPEG command not running from php but working in cmd
i have this function in my laravel controller

```<code>foreach ($arrayi['audio'] as $i => $audioFile) {
            // Loop through the audio files and image files
                // Create a new video with the audio file and image file
                $dimensions = "1024x1024";
                // Set the audio and image file paths
                $audioPath = public_path("storage/{$arrayi['audio'][$i]}");
                $imagePath = public_path("storage/{$arrayi['links'][$i]}");
                $duration = exec("ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {$audioPath}");
                // Set the command to create the video
                $command =exec("ffmpeg -loop 1 -i {$audioPath} -i {$imagePath} -t {$duration}  -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p output_{$i}.mp4");

                // Add the output video to the array of output videos
                $outputVideos[] = public_path("storage/output_{$i}.mp4");
            }
</code>```

which is supposed to create multiple videos by running the ffmpeg command one by one for each image and audio. this is all done after clicking a button in browser.

I've tried printing the $command and then running it in cmd in windows and it all works fine but when i do it through the browser nothing happens. the $duration command works fine it passes the duration to the ffmpeg command .

Body:
i have this function in my laravel controller

foreach ($arrayi['audio'] as $i => $audioFile) {
            // Loop through the audio files and image files
                // Create a new video with the audio file and image file
                $dimensions = "1024x1024";
                // Set the audio and image file paths
                $audioPath = public_path("storage/{$arrayi['audio'][$i]}");
                $imagePath = public_path("storage/{$arrayi['links'][$i]}");
                $duration = exec("ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 {$audioPath}");
                // Set the command to create the video
                $command =exec("ffmpeg -loop 1 -i {$audioPath} -i {$imagePath} -t {$duration}  -c:v libx264 -tune stillimage -c:a aac -b:a 192k -pix_fmt yuv420p output_{$i}.mp4");

                // Add the output video to the array of output videos
                $outputVideos[] = public_path("storage/output_{$i}.mp4");
            }

which is supposed to create multiple videos by running the ffmpeg command one by one for each image and audio. this is all done after clicking a button in browser.

I've tried printing the $command and then running it in cmd in windows and it all works fine but when i do it through the browser nothing happens. the $duration command works fine it passes the duration to the ffmpeg command .


来源: stackexchange

问:
Saving an object to a Json file as a key
I have a LinkedHashMap that contains two objects which both reside inside a normal HashMap. All 3 objects inside these maps have hashCode, equals, and toString methods. The "Chunk" object contains 3 variables a string and 2 integers all are final. The Location object only contains a string and 3 integers which are also final. Lastly, the ChestObject contains an enum and a list of other enums.

```<code>public static Map<Chunk, LinkedHashMap<Location, ChestObject>> CHEST_MAP = new HashMap<>();

public class Location {
private final String worldName;
private final int x;
private final int y;
private final int z;

public class Chunk {
private final String worldName;
private final int x;
private final int z;

public class ChestObject {
public List<Material> filteredMaterials = new ArrayList<>();
private ChestType chestType;
</code>```

Saving the map works perfectly but retrieving the info throws the following error.

```<code>[17:17:53 WARN]: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 2 column 4 [17:17:53 WARN]:
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176) [17:17:53 WARN]:
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) [17:17:53 WARN]:
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:186) [17:17:53 WARN]:
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145) [17:17:53 WARN]:
        at com.google.gson.Gson.fromJson(Gson.java:803) [17:17:53 WARN]:
        at com.google.gson.Gson.fromJson(Gson.java:768) [17:17:53 WARN]:
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 2 column 4 [17:17:53 WARN]:
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:374) [17:17:53 WARN]:
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165) [17:17:53 WARN]:
        ... 18 more
</code>```

The file it attempts to read is the following...

```<code>{
  "WorldName:world X:-3 Z:-64": {
    "WorldName:world X:-39 Y:63 Z:-1016": {
      "filteredMaterials": [
        "ROTTEN_FLESH"
      ],
      "chestType": "DOUBLE"
    },
    "WorldName:world X:-40 Y:63 Z:-1016": {
      "filteredMaterials": [
        "ROTTEN_FLESH"
      ],
      "chestType": "DOUBLE"
    }
  }
}
</code>```

The last bit of useful info is my recovery method which at this moment just attempts to print the map instead of assigning it to CHEST_MAP.

```<code>private void recoverChests() {
    final File file = new File(getDataFolder(), "chests.json");

    if(file.exists() && file.length() > 2) {
        try {
            final Gson gson = new GsonBuilder().setPrettyPrinting().create();
            final Type type = new TypeToken<Map<Chunk, LinkedHashMap<Location, ChestObject>>>() {}.getType();
            final Map<Chunk, LinkedHashMap<Location, ChestObject>> map = gson.fromJson(new FileReader(file), type);
            System.out.println("Map: " + map);
        } catch (IllegalStateException | JsonSyntaxException | IOException e) {
            e.printStackTrace();
        }
    }
}
</code>```

So based on the above error it appears that Json is having a hard time serializing object keys while it has no trouble doing the same for values. This is shown above since we can see Json saving the data as a String instead of an object like it did with our ChestObject. So how can I correctly save the above data so that Json correctly serializes key objects?

```<code> private void saveChests() {
        try {
            if(!CHEST_MAP.isEmpty()) {
                final File file = new File(this.getDataFolder(), "chests.json");
                final Gson gson = new GsonBuilder().setPrettyPrinting().create();
                final Writer writer = new FileWriter(file);

                gson.toJson(CHEST_MAP, writer);
                writer.flush();
                writer.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
</code>```

ContentLicense: CC BY-SA 4.0

Body:
I have a LinkedHashMap that contains two objects which both reside inside a normal HashMap. All 3 objects inside these maps have hashCode, equals, and toString methods. The "Chunk" object contains 3 variables a string and 2 integers all are final. The Location object only contains a string and 3 integers which are also final. Lastly, the ChestObject contains an enum and a list of other enums.

public static Map<Chunk, LinkedHashMap<Location, ChestObject>> CHEST_MAP = new HashMap<>();

public class Location {
private final String worldName;
private final int x;
private final int y;
private final int z;

public class Chunk {
private final String worldName;
private final int x;
private final int z;

public class ChestObject {
public List<Material> filteredMaterials = new ArrayList<>();
private ChestType chestType;

Saving the map works perfectly but retrieving the info throws the following error.

[17:17:53 WARN]: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 2 column 4 [17:17:53 WARN]:
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:176) [17:17:53 WARN]:
        at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:40) [17:17:53 WARN]:
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:186) [17:17:53 WARN]:
        at com.google.gson.internal.bind.MapTypeAdapterFactory$Adapter.read(MapTypeAdapterFactory.java:145) [17:17:53 WARN]:
        at com.google.gson.Gson.fromJson(Gson.java:803) [17:17:53 WARN]:
        at com.google.gson.Gson.fromJson(Gson.java:768) [17:17:53 WARN]:
Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 2 column 4 [17:17:53 WARN]:
        at com.google.gson.stream.JsonReader.beginObject(JsonReader.java:374) [17:17:53 WARN]:
        at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:165) [17:17:53 WARN]:
        ... 18 more

The file it attempts to read is the following...

{
  "WorldName:world X:-3 Z:-64": {
    "WorldName:world X:-39 Y:63 Z:-1016": {
      "filteredMaterials": [
        "ROTTEN_FLESH"
      ],
      "chestType": "DOUBLE"
    },
    "WorldName:world X:-40 Y:63 Z:-1016": {
      "filteredMaterials": [
        "ROTTEN_FLESH"
      ],
      "chestType": "DOUBLE"
    }
  }
}

The last bit of useful info is my recovery method which at this moment just attempts to print the map instead of assigning it to CHEST_MAP.

private void recoverChests() {
    final File file = new File(getDataFolder(), "chests.json");

    if(file.exists() && file.length() > 2) {
        try {
            final Gson gson = new GsonBuilder().setPrettyPrinting().create();
            final Type type = new TypeToken<Map<Chunk, LinkedHashMap<Location, ChestObject>>>() {}.getType();
            final Map<Chunk, LinkedHashMap<Location, ChestObject>> map = gson.fromJson(new FileReader(file), type);
            System.out.println("Map: " + map);
        } catch (IllegalStateException | JsonSyntaxException | IOException e) {
            e.printStackTrace();
        }
    }
}

So based on the above error it appears that Json is having a hard time serializing object keys while it has no trouble doing the same for values. This is shown above since we can see Json saving the data as a String instead of an object like it did with our ChestObject. So how can I correctly save the above data so that Json correctly serializes key objects?

 private void saveChests() {
        try {
            if(!CHEST_MAP.isEmpty()) {
                final File file = new File(this.getDataFolder(), "chests.json");
                final Gson gson = new GsonBuilder().setPrettyPrinting().create();
                final Writer writer = new FileWriter(file);

                gson.toJson(CHEST_MAP, writer);
                writer.flush();
                writer.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


问:
Problem displaying an expandable list android studio java
I have made a page allowing to see tools arranged in classes and subclasses (3rd floor).
The tools database is on a server, and I receive the data as JSON.

Everything was working fine until I added a number of tools (and therefore classes)
My tools appear several times without reason in classes that are not the right ones.
I checked the JSON, no problem.
Here are screenshots of the problem and the code that allows me to retrieve the data and send it to my adapter.
Thanks for your help.

Random display problem image 1

Random display problem image 2

Random display problem image 3

ArrayList<String> famille1 = new ArrayList<>();
ArrayList<String> typeliste = new ArrayList<>();
HashMap<String, HashMap<String, HashMap<String, ArrayList<MatosItem>>>> ma = new HashMap<>();
ArrayList<String> materiauliste = new ArrayList<>();
HashMap<String, HashMap<String, HashMap<String, ArrayList<MatosItem>>>> materielsItemList = new HashMap<>();
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
    @Override
    public void run() {
        FetchData fetchData = new FetchData("http://" + adresseIp.getAdresseIP() + "/jsonmateriels.php");
        if (fetchData.startFetch()) {
            if (fetchData.onComplete()) {
                String json = fetchData.getResult();
                        try {
                            HashMap<String, HashMap<String, ArrayList<MatosItem>>> typeItemList = new HashMap<>();
                            JSONObject jsonObject = new JSONObject(json);
                            JSONArray jsonArrayOutils = jsonObject.getJSONArray("Outils");
                            for (int j = 0; j < jsonArrayOutils.length(); j++) {
                                HashMap<String, HashMap<String, ArrayList<MatosItem>>> typeItemList1 = new HashMap<>();
                                JSONObject fam = jsonArrayOutils.getJSONObject(j);
                                String famille = fam.names().getString(0);//permet d'avoir les choses contenu dans la classe soudeurs
                                JSONArray jsonArrayFamille = fam.getJSONArray(famille);//permet de récupérer le suivant
                                famille1.add(famille);
                                for (int i = 0; i < jsonArrayFamille.length(); i++) {
                                    HashMap<String, ArrayList<MatosItem>> matItemList = new HashMap<>();
                                    JSONObject typ = jsonArrayFamille.getJSONObject(i);
                                    String type = typ.names().getString(0);
                                    JSONArray jsonArrayType = typ.getJSONArray(type);
                                    typeliste.add(type);
                                    for (int k = 0; k < jsonArrayType.length(); k++) {
                                        JSONObject mat = jsonArrayType.getJSONObject(k);
                                        ArrayList<MatosItem> outils = new ArrayList<>();
                                        String materiau = mat.names().getString(0);
                                        JSONArray jsonArraylistout = mat.getJSONArray(materiau);
                                        materiauliste.add(materiau);
                                        for (int l = 0; l < jsonArraylistout.length(); l++) {
                                            JSONObject out = jsonArraylistout.getJSONObject(l);
                                            String description = out.getString("description");
                                            String id = out.getString("id");
                                            String ref = out.getString("ref");
                                            String code_fourn = out.getString("code_fourn");
                                            Log.e("boucle",description+id);
                                            outils.add(new MatosItem(description, id, false, ref, code_fourn));
                                        }
                                        matItemList.put(materiau, outils);
                                    }
                                    typeItemList1.put(type, matItemList);
                                }
                                materielsItemList.put(famille, typeItemList1);
                                tabLayout.addTab(tabLayout.newTab().setText(famille));

                            }
                            ArrayList<String> list = new ArrayList<>();

                             for (String i : Objects.requireNonNull(materielsItemList.get(famille1.get(0))).keySet()) {
                                list.add(i);
                                 Log.e(TAG, "run: "+i );
                            }

                            typeItemList = materielsItemList.get(famille1.get(0));
                            Log.e(TAG, "run: "+typeItemList );
                            matosListView.setAdapter(new MatosItemAdapter(context, typeItemList,list ));
                            tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                                @Override
                                public void onTabSelected(TabLayout.Tab tab) {
                                    // get the current selected tab's position and replace the fragment accordingly
                                    Fragment fragment = null;
                                    if (tab.isSelected()) {
                                        ArrayList<String> list = new ArrayList<>();
                                        for (String i : Objects.requireNonNull(materielsItemList.get(famille1.get(tab.getPosition()))).keySet()) {
                                            list.add(i);
                                        }
                                        HashMap<String, HashMap<String, ArrayList<MatosItem>>> typeItemList1 = new HashMap<>();
                                        typeItemList1 = materielsItemList.get(famille1.get(tab.getPosition()));
                                        matosListView.setAdapter(new MatosItemAdapter(context, typeItemList1, list));
                                    }

                                    FragmentManager fm = getSupportFragmentManager();
                                    FragmentTransaction ft = fm.beginTransaction();
                                    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                                    ft.commit();
                                }

                                @Override
                                public void onTabUnselected(TabLayout.Tab tab) {

                                }

                                @Override
                                public void onTabReselected(TabLayout.Tab tab) {

                                }
                            });
                            progressBar.setVisibility(GONE);

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
            }
        }
    }
});
```
<p>I checked the JSON
I tried to use a thread</p>
<pre class="lang-json prettyprint-override"><code>{
    "Outils" : [{
        "Soudeurs" : [
        {
            "Fils" : [
            {
                "Fil" : [
                {
                    "description" : "Fil MIG G3SI1 diam 1.2",
                    "id" : "26",
                    "ref" : "bobine de 15 kg",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Fourre OK1413 diam 1.2",
                    "id" : "45",
                    "ref" : "bobine 16 kg avec gaz",
                    "code_fourn" : "x"
                },
                {
                    "description" : "MIG inox 316L SI diam 1.2",
                    "id" : "46",
                    "ref" : "bobine 15 kg",
                    "code_fourn" : "x"
                }]
            }]
        },
        {
            "Materiel de soudure" : [
            {
                "Gaine guide" : [
                {
                    "description" : "fil 25 x 45 4M diam 1.2",
                    "id" : "27",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Batterie" : [
                {
                    "description" : "Warrior AIR ESAB",
                    "id" : "47",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Cagoule" : [
                {
                    "description" : "Couvre nuque noire ESAB",
                    "id" : "48",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Protection" : [
                {
                    "description" : "Ecran de protection bleu",
                    "id" : "49",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Visiere transparente pour ecran HG930B",
                    "id" : "50",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Visiere teinte pour ecran HG930B",
                    "id" : "51",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Pince" : [
                {
                    "description" : "Stubby original 400 A",
                    "id" : "52",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Masse bronze GCB 450 A",
                    "id" : "53",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Masse bronze GCB 600 A",
                    "id" : "54",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            }]
        },
        {
            "Electrodes" : [
            {
                "OK4627" : [
                {
                    "description" : "Diam 2.5 x 350 rutile",
                    "id" : "25",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "OK4800" : [
                {
                    "description" : "Diam 2.5 x 350",
                    "id" : "32",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 3.2 x 350",
                    "id" : "33",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 4 x 350",
                    "id" : "34",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 5 x 450",
                    "id" : "35",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "Inox 316 L 17" : [
                {
                    "description" : "Diam 2.5 x 300",
                    "id" : "36",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 3.2 x 350",
                    "id" : "37",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 4 x 350",
                    "id" : "38",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "Gougeage" : [
                {
                    "description" : "6 x 305",
                    "id" : "39",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "8 x 305",
                    "id" : "40",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "10 x 305",
                    "id" : "41",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "Nue" : [
                {
                    "description" : "9.5 x 914 slice",
                    "id" : "42",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            }]
        }]},
        {
            "Ajusteurs" : [
            {
                "Accessoires" : [
                {
                    "Nettoyant" : [
                    {
                        "description" : "26.5 kg alfa marine",
                        "id" : "44",
                        "ref" : "x",
                        "code_fourn" : "x"
                    }]
                }]
            },
            {
                "Hydraulique" : [
                {
                    "Huile" : [
                    {
                        "description" : "Enerpac HF95Y bidon 5L",
                        "id" : "43",
                        "ref" : "x",
                        "code_fourn" : "x"
                    }]
                }]
            }]
        },
        {
            "Machinistes" : [
            {
                "Accessoires" : [
                {
                    "Lame ebavureur" : [
                    {
                        "description" : "E100S (longue) boite de 10",
                        "id" : "30",
                        "ref" : "x",
                        "code_fourn" : "x"
                    },
                    {
                        "description" : "B10S (courte) boite de 10",
                        "id" : "31",
                        "ref" : "x",
                        "code_fourn" : "x"
                    }]
                }]
            }]
        }]
    }

</code>```

I would like to have a correct display of the tools and their class. I don't have to have expandables list

Body:
I have made a page allowing to see tools arranged in classes and subclasses (3rd floor).
The tools database is on a server, and I receive the data as JSON.

Everything was working fine until I added a number of tools (and therefore classes)
My tools appear several times without reason in classes that are not the right ones.
I checked the JSON, no problem.
Here are screenshots of the problem and the code that allows me to retrieve the data and send it to my adapter.
Thanks for your help.

Random display problem image 1

Random display problem image 2

Random display problem image 3

ArrayList<String> famille1 = new ArrayList<>();
ArrayList<String> typeliste = new ArrayList<>();
HashMap<String, HashMap<String, HashMap<String, ArrayList<MatosItem>>>> ma = new HashMap<>();
ArrayList<String> materiauliste = new ArrayList<>();
HashMap<String, HashMap<String, HashMap<String, ArrayList<MatosItem>>>> materielsItemList = new HashMap<>();
Handler handler = new Handler(Looper.getMainLooper());
handler.post(new Runnable() {
    @Override
    public void run() {
        FetchData fetchData = new FetchData("http://" + adresseIp.getAdresseIP() + "/jsonmateriels.php");
        if (fetchData.startFetch()) {
            if (fetchData.onComplete()) {
                String json = fetchData.getResult();
                        try {
                            HashMap<String, HashMap<String, ArrayList<MatosItem>>> typeItemList = new HashMap<>();
                            JSONObject jsonObject = new JSONObject(json);
                            JSONArray jsonArrayOutils = jsonObject.getJSONArray("Outils");
                            for (int j = 0; j < jsonArrayOutils.length(); j++) {
                                HashMap<String, HashMap<String, ArrayList<MatosItem>>> typeItemList1 = new HashMap<>();
                                JSONObject fam = jsonArrayOutils.getJSONObject(j);
                                String famille = fam.names().getString(0);//permet d'avoir les choses contenu dans la classe soudeurs
                                JSONArray jsonArrayFamille = fam.getJSONArray(famille);//permet de récupérer le suivant
                                famille1.add(famille);
                                for (int i = 0; i < jsonArrayFamille.length(); i++) {
                                    HashMap<String, ArrayList<MatosItem>> matItemList = new HashMap<>();
                                    JSONObject typ = jsonArrayFamille.getJSONObject(i);
                                    String type = typ.names().getString(0);
                                    JSONArray jsonArrayType = typ.getJSONArray(type);
                                    typeliste.add(type);
                                    for (int k = 0; k < jsonArrayType.length(); k++) {
                                        JSONObject mat = jsonArrayType.getJSONObject(k);
                                        ArrayList<MatosItem> outils = new ArrayList<>();
                                        String materiau = mat.names().getString(0);
                                        JSONArray jsonArraylistout = mat.getJSONArray(materiau);
                                        materiauliste.add(materiau);
                                        for (int l = 0; l < jsonArraylistout.length(); l++) {
                                            JSONObject out = jsonArraylistout.getJSONObject(l);
                                            String description = out.getString("description");
                                            String id = out.getString("id");
                                            String ref = out.getString("ref");
                                            String code_fourn = out.getString("code_fourn");
                                            Log.e("boucle",description+id);
                                            outils.add(new MatosItem(description, id, false, ref, code_fourn));
                                        }
                                        matItemList.put(materiau, outils);
                                    }
                                    typeItemList1.put(type, matItemList);
                                }
                                materielsItemList.put(famille, typeItemList1);
                                tabLayout.addTab(tabLayout.newTab().setText(famille));

                            }
                            ArrayList<String> list = new ArrayList<>();

                             for (String i : Objects.requireNonNull(materielsItemList.get(famille1.get(0))).keySet()) {
                                list.add(i);
                                 Log.e(TAG, "run: "+i );
                            }

                            typeItemList = materielsItemList.get(famille1.get(0));
                            Log.e(TAG, "run: "+typeItemList );
                            matosListView.setAdapter(new MatosItemAdapter(context, typeItemList,list ));
                            tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
                                @Override
                                public void onTabSelected(TabLayout.Tab tab) {
                                    // get the current selected tab's position and replace the fragment accordingly
                                    Fragment fragment = null;
                                    if (tab.isSelected()) {
                                        ArrayList<String> list = new ArrayList<>();
                                        for (String i : Objects.requireNonNull(materielsItemList.get(famille1.get(tab.getPosition()))).keySet()) {
                                            list.add(i);
                                        }
                                        HashMap<String, HashMap<String, ArrayList<MatosItem>>> typeItemList1 = new HashMap<>();
                                        typeItemList1 = materielsItemList.get(famille1.get(tab.getPosition()));
                                        matosListView.setAdapter(new MatosItemAdapter(context, typeItemList1, list));
                                    }

                                    FragmentManager fm = getSupportFragmentManager();
                                    FragmentTransaction ft = fm.beginTransaction();
                                    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
                                    ft.commit();
                                }

                                @Override
                                public void onTabUnselected(TabLayout.Tab tab) {

                                }

                                @Override
                                public void onTabReselected(TabLayout.Tab tab) {

                                }
                            });
                            progressBar.setVisibility(GONE);

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }
            }
        }
    }
});

I checked the JSON
I tried to use a thread

{
    "Outils" : [{
        "Soudeurs" : [
        {
            "Fils" : [
            {
                "Fil" : [
                {
                    "description" : "Fil MIG G3SI1 diam 1.2",
                    "id" : "26",
                    "ref" : "bobine de 15 kg",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Fourre OK1413 diam 1.2",
                    "id" : "45",
                    "ref" : "bobine 16 kg avec gaz",
                    "code_fourn" : "x"
                },
                {
                    "description" : "MIG inox 316L SI diam 1.2",
                    "id" : "46",
                    "ref" : "bobine 15 kg",
                    "code_fourn" : "x"
                }]
            }]
        },
        {
            "Materiel de soudure" : [
            {
                "Gaine guide" : [
                {
                    "description" : "fil 25 x 45 4M diam 1.2",
                    "id" : "27",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Batterie" : [
                {
                    "description" : "Warrior AIR ESAB",
                    "id" : "47",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Cagoule" : [
                {
                    "description" : "Couvre nuque noire ESAB",
                    "id" : "48",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Protection" : [
                {
                    "description" : "Ecran de protection bleu",
                    "id" : "49",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Visiere transparente pour ecran HG930B",
                    "id" : "50",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Visiere teinte pour ecran HG930B",
                    "id" : "51",
                    "ref" : "x",
                    "code_fourn" : "x"
                }
            ]},
            {
                "Pince" : [
                {
                    "description" : "Stubby original 400 A",
                    "id" : "52",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Masse bronze GCB 450 A",
                    "id" : "53",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Masse bronze GCB 600 A",
                    "id" : "54",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            }]
        },
        {
            "Electrodes" : [
            {
                "OK4627" : [
                {
                    "description" : "Diam 2.5 x 350 rutile",
                    "id" : "25",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "OK4800" : [
                {
                    "description" : "Diam 2.5 x 350",
                    "id" : "32",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 3.2 x 350",
                    "id" : "33",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 4 x 350",
                    "id" : "34",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 5 x 450",
                    "id" : "35",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "Inox 316 L 17" : [
                {
                    "description" : "Diam 2.5 x 300",
                    "id" : "36",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 3.2 x 350",
                    "id" : "37",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "Diam 4 x 350",
                    "id" : "38",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "Gougeage" : [
                {
                    "description" : "6 x 305",
                    "id" : "39",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "8 x 305",
                    "id" : "40",
                    "ref" : "x",
                    "code_fourn" : "x"
                },
                {
                    "description" : "10 x 305",
                    "id" : "41",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            },
            {
                "Nue" : [
                {
                    "description" : "9.5 x 914 slice",
                    "id" : "42",
                    "ref" : "x",
                    "code_fourn" : "x"
                }]
            }]
        }]},
        {
            "Ajusteurs" : [
            {
                "Accessoires" : [
                {
                    "Nettoyant" : [
                    {
                        "description" : "26.5 kg alfa marine",
                        "id" : "44",
                        "ref" : "x",
                        "code_fourn" : "x"
                    }]
                }]
            },
            {
                "Hydraulique" : [
                {
                    "Huile" : [
                    {
                        "description" : "Enerpac HF95Y bidon 5L",
                        "id" : "43",
                        "ref" : "x",
                        "code_fourn" : "x"
                    }]
                }]
            }]
        },
        {
            "Machinistes" : [
            {
                "Accessoires" : [
                {
                    "Lame ebavureur" : [
                    {
                        "description" : "E100S (longue) boite de 10",
                        "id" : "30",
                        "ref" : "x",
                        "code_fourn" : "x"
                    },
                    {
                        "description" : "B10S (courte) boite de 10",
                        "id" : "31",
                        "ref" : "x",
                        "code_fourn" : "x"
                    }]
                }]
            }]
        }]
    }

I would like to have a correct display of the tools and their class. I don't have to have expandables list


问:
C++ memcpy - defective address
I have a vector that receives bytes from the network:

```<code>std:vector<unsigned char> data
</code>```

I am trying to copy the address of the data into an unsigned char *[] array:

```<code>unsigned char *buffer = new unsigned char [1024*1024]
</code>```

I am trying to loop through it to find a valid data packet that I am looking for. The sample code is below.

When I try to do memcpy to process the data I get an error saying defective address.

```<code>//process data
        unsigned char * processPtr = NULL;
        memcpy((void *) processPtr, hdr, sizeof(Header));
        memcpy((void *) (processPtr + sizeof(Header)), (void *) ((unsigned char *) hdr + sizeof(Header))), hdr-> nubBytes);
</code>```

Appreciate some help on this

header file:

```<code>typedef struct {
    uint word;
    int id;
    int nubBytes;
}Header;

#define WORD 0xA345
unsigned char * buffer = new unsigned char[1024*1024];
Header *hdr;
int pktOffset;
cpp file:
Decode msg(std:vector<unsigned char> data, uint32_t bytesrcvd){
    pktOffset = 0;
    buffer = &data[0];
    rcvBufOffSet += bytesRcvd;
    numBytesInRecBuff += bytesRcvd;
    hdr = (Header *)(& buffer[pktOffset])
    if(hdr->word != WORD){
        while(hdr->word != WORD && numBytesInRecBuff > 0)
            pktOffset++;
            numBytesInRecBuff--;
            hdr = (Header *)(& Buffer[pktOffset])
    }
    if(hdr->word != WORD){
        return;
    }
    else{
    //process data
        unsigned char * processPtr = NULL;
        memcpy((void *) processPtr, hdr, sizeof(Header));
        memcpy((void *) (processPtr + sizeof(Header)), (void *) ((unsigned char *) hdr + sizeof(Header))), hdr-> nubBytes);

processPacket((Header *)processPtr, unsigned char * (processPtr + + sizeof(Header)));
    }
}

processPacket(Header * hdrPtr, unsigned char * dataPtr){
    //further processing
}
</code>```

Title: C++ memcpy - defective address

Body:
I have a vector that receives bytes from the network:

std:vector<unsigned char> data

I am trying to copy the address of the data into an unsigned char *[] array:

unsigned char *buffer = new unsigned char [1024*1024]

I am trying to loop through it to find a valid data packet that I am looking for. The sample code is below.

When I try to do memcpy to process the data I get an error saying defective address.

//process data
        unsigned char * processPtr = NULL;
        memcpy((void *) processPtr, hdr, sizeof(Header));
        memcpy((void *) (processPtr + sizeof(Header)), (void *) ((unsigned char *) hdr + sizeof(Header))), hdr-> nubBytes);

Appreciate some help on this

header file:

typedef struct {
    uint word;
    int id;
    int nubBytes;
}Header;

#define WORD 0xA345
unsigned char * buffer = new unsigned char[1024*1024];
Header *hdr;
int pktOffset;
cpp file:
Decode msg(std:vector<unsigned char> data, uint32_t bytesrcvd){
    pktOffset = 0;
    buffer = &data[0];
    rcvBufOffSet += bytesRcvd;
    numBytesInRecBuff += bytesRcvd;
    hdr = (Header *)(& buffer[pktOffset])
    if(hdr->word != WORD){
        while(hdr->word != WORD && numBytesInRecBuff > 0)
            pktOffset++;
            numBytesInRecBuff--;
            hdr = (Header *)(& Buffer[pktOffset])
    }
    if(hdr->word != WORD){
        return;
    }
    else{
    //process data
        unsigned char * processPtr = NULL;
        memcpy((void *) processPtr, hdr, sizeof(Header));
        memcpy((void *) (processPtr + sizeof(Header)), (void *) ((unsigned char *) hdr + sizeof(Header))), hdr-> nubBytes);

processPacket((Header *)processPtr, unsigned char * (processPtr + + sizeof(Header)));
    }
}

processPacket(Header * hdrPtr, unsigned char * dataPtr){
    //further processing
}


问:
Python find broken symlinks caused by Git
I'm currently working on a script that is supposed to go through a cloned Git repo and remove any existing symlinks (broken or not) before recreating them for the user to ease with project initialization.

The solved problems:

Finding symbolic links (broken or unbroken) in Python is very well documented.

GitHub/GitLab breaking symlinks upon downloading/cloning/updating repositories is also very well documented as is how to fix this problem. Tl;dr: Git will download symlinks within the repo as plain text files (with no extension) containing only the symlink path if certain config flags are not set properly.

The unsolved problem:

My problem is that developers may download this repo without realizing the issues with Git, and end up with the symbolic links "checked out as small plain files that contain the link text" which is completely undetectable (as far as I can tell) when parsing the cloned files/directories (via existing base libraries). Running os.stat() on one of these broken symlink files returns information as though it were a normal text file:

os.stat_result(st_mode=33206, st_ino=14073748835637675, st_dev=2149440935, st_nlink=1, st_uid=0, st_gid=0, st_size=42, st_atime=1671662717, st_mtime=1671662699, st_ctime=1671662699)
```
<p>The <code>st_mode</code> information only indicates that it is a normal text file- <code>100666</code> (the first 3 digits are the file type and the last 3 are the UNIX-style permissions). It should show up as <code>120000</code>.</p>
<p>The <code>os.path.islink()</code> function only ever returns <code>False</code>.</p>
<p>THE CONFUSING PART is that when I run <code>git ls-files -s ./microservices/service/symlink_file</code> it gives <code>1200000</code> as the mode bits which, according to the documentation, indicates that  this file is a symlink. However I cannot figure out how to see this information from within Python.</p>
<p>I've tried a bunch of things to try and find and delete existing symlinks. Here's the base method that just finds symlink directories and then deletes them:</p>
<pre class="lang-python prettyprint-override"><code>def clearsymlinks(cwd: str = ""):
    """
    Crawls starting from root directory and deletes all symlinks
    within the directory tree.
    """
    if not cwd:
        cwd = os.getcwd()

    print(f"Clearing symlinks - starting from {cwd}")
    # Create a queue
    cwd_dirs: list[str] = [cwd]
    while len(cwd_dirs) > 0:
        processing_dir: str = cwd_dirs.pop()
        # print(f"Processing {processing_dir}")  # Only when debugging - else it's too much output spam
        for child_dir in os.listdir(processing_dir):
            child_dir_path = os.path.join(processing_dir, child_dir)

            # check if current item is a directory
            if not os.path.isdir(child_dir_path):
                if os.path.islink(child_dir_path):
                    print(f"-- Found symbolic link file {child_dir_path} - removing.\n")
                    os.remove(child_dir_path)

                # skip the dir checking
                continue

            # Check if the child dir is a symlink
            if os.path.islink(child_dir_path):
                print(f"-- Found symlink directory {child_dir_path} - removing.")
                os.remove(child_dir_path)
            else:
                # Add the child dir to the queue
                cwd_dirs.append(child_dir_path)
</code>```

After deleting symlinks I run os.symlink(symlink_src, symlink_dst) and generally run into the following error:

Traceback (most recent call last):
  File "C:\Users\me\my_repo\remakesymlinks.py", line 123, in main
    os.symlink(symlink_src, symlink_dst)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\\Users\\me\\my_repo\\SharedPy' -> 'C:\\Users\\me\\my_repo\\microservices\\service\\symlink_file'
```
<p>A workaround to specifically this error (inside the create symlink method) is:</p>
<pre class="lang-python prettyprint-override"><code>try:
    os.symlink(symlink_src, symlink_dst)
except FileExistsError:
    os.remove(symlink_dst)
    os.symlink(symlink_src, symlink_dst)
</code>```

But this is not ideal because it doesn't prevent a huge list of defunct/broken symlinks from piling up in the directory. I should be able to find any symlinks (working, broken, non-existent, etc.) and then delete them.

I have a list of the symlinks that should be created by my script, but extracting the list of targets from this list is also a workaround that also causes a 'symlink-leak'. Below is how I'm currently finding the broken symlink purely for testing purposes.

if not os.path.isdir(child_dir_path):
    if os.path.basename(child_dir_path) in [s.symlink_install_to for s in dirs_to_process]:
        print(f"-- Found symlink file {child_dir_path} - removing.")
        os.remove(child_dir_path)

    # skip the dir checking
    continue
```
<p>A rudimentary solution where I filter for only 'text/plain' files with exactly 1 line (since checking anything else is pointless) and trying to determine whether that single line is just a file path (this seems excessive though):</p>
<pre class="lang-python prettyprint-override"><code># Check if Git downloaded the symlink as a plain text file (undetectable broken symlink)
if not os.path.isdir(child_dir_path):
    try:
        if magic.Magic(mime = True, uncompress = True).from_file(child_dir_path) == 'text/plain':
            with open(child_dir_path, 'r') as file:
                for i, line in enumerate(file):
                    if i >= 1:
                        raise StopIteration
                else:
                    # this function is directly copied from https://stackoverflow.com/a/34102855/8705841
                    if is_path_exists_or_creatable(line):
                        print(f"-- Found broken Git link file '{child_dir_path}' - removing.")
                        print(f"\tContents: \"{line}\"")
                        # os.remove(child_dir_path)
                        raise StopIteration
    except (StopIteration, UnicodeDecodeError, magic.MagicException):
        file.close()
        continue
</code>```

Clearly this solution would require a lot of refactoring (9 indents is pretty ridiculous) if it's the only viable option. Problem with this solution (currently) is that it also tries to delete any single-line files with a string that does not break pathname requirements- i.e. import _virtualenv, some random test string, project-name. Filtering out those files with spaces, or files without slashes, could potentially work but this still feels like chasing edge cases instead of solving the actual problem.

I could potentially rewrite this script in Bash wherein I could, in addition to existing symlink search/destroy code, parse the results from git ls-files -s ... and then delete any files with the 120000 tag. But is this method feasible and/or reliable? There should be a way to do this from within Python since Bash isn't going to run on every OS.

Note: file names have been redacted/changed after copy-paste for privacy, they shouldn't matter anyways since they are generated dynamically by the path searching functions

Body:
I'm currently working on a script that is supposed to go through a cloned Git repo and remove any existing symlinks (broken or not) before recreating them for the user to ease with project initialization.

The solved problems:

Finding symbolic links (broken or unbroken) in Python is very well documented.

GitHub/GitLab breaking symlinks upon downloading/cloning/updating repositories is also very well documented as is how to fix this problem. Tl;dr: Git will download symlinks within the repo as plain text files (with no extension) containing only the symlink path if certain config flags are not set properly.

The unsolved problem:

My problem is that developers may download this repo without realizing the issues with Git, and end up with the symbolic links "checked out as small plain files that contain the link text" which is completely undetectable (as far as I can tell) when parsing the cloned files/directories (via existing base libraries). Running os.stat() on one of these broken symlink files returns information as though it were a normal text file:

os.stat_result(st_mode=33206, st_ino=14073748835637675, st_dev=2149440935, st_nlink=1, st_uid=0, st_gid=0, st_size=42, st_atime=1671662717, st_mtime=1671662699, st_ctime=1671662699)

The st_mode information only indicates that it is a normal text file- 100666 (the first 3 digits are the file type and the last 3 are the UNIX-style permissions). It should show up as 120000.

The os.path.islink() function only ever returns False.

THE CONFUSING PART is that when I run git ls-files -s ./microservices/service/symlink_file it gives 1200000 as the mode bits which, according to the documentation, indicates that  this file is a symlink. However I cannot figure out how to see this information from within Python.

I've tried a bunch of things to try and find and delete existing symlinks. Here's the base method that just finds symlink directories and then deletes them:

def clearsymlinks(cwd: str = ""):
    """
    Crawls starting from root directory and deletes all symlinks
    within the directory tree.
    """
    if not cwd:
        cwd = os.getcwd()

    print(f"Clearing symlinks - starting from {cwd}")
    # Create a queue
    cwd_dirs: list[str] = [cwd]
    while len(cwd_dirs) > 0:
        processing_dir: str = cwd_dirs.pop()
        # print(f"Processing {processing_dir}")  # Only when debugging - else it's too much output spam
        for child_dir in os.listdir(processing_dir):
            child_dir_path = os.path.join(processing_dir, child_dir)

            # check if current item is a directory
            if not os.path.isdir(child_dir_path):
                if os.path.islink(child_dir_path):
                    print(f"-- Found symbolic link file {child_dir_path} - removing.\n")
                    os.remove(child_dir_path)

                # skip the dir checking
                continue

            # Check if the child dir is a symlink
            if os.path.islink(child_dir_path):
                print(f"-- Found symlink directory {child_dir_path} - removing.")
                os.remove(child_dir_path)
            else:
                # Add the child dir to the queue
                cwd_dirs.append(child_dir_path)

After deleting symlinks I run os.symlink(symlink_src, symlink_dst) and generally run into the following error:

Traceback (most recent call last):
  File "C:\Users\me\my_repo\remakesymlinks.py", line 123, in main
    os.symlink(symlink_src, symlink_dst)
FileExistsError: [WinError 183] Cannot create a file when that file already exists: 'C:\\Users\\me\\my_repo\\SharedPy' -> 'C:\\Users\\me\\my_repo\\microservices\\service\\symlink_file'

A workaround to specifically this error (inside the create symlink method) is:

try:
    os.symlink(symlink_src, symlink_dst)
except FileExistsError:
    os.remove(symlink_dst)
    os.symlink(symlink_src, symlink_dst)

But this is not ideal because it doesn't prevent a huge list of defunct/broken symlinks from piling up in the directory. I should be able to find any symlinks (working, broken, non-existent, etc.) and then delete them.

I have a list of the symlinks that should be created by my script, but extracting the list of targets from this list is also a workaround that also causes a 'symlink-leak'. Below is how I'm currently finding the broken symlink purely for testing purposes.

if not os.path.isdir(child_dir_path):
    if os.path.basename(child_dir_path) in [s.symlink_install_to for s in dirs_to_process]:
        print(f"-- Found symlink file {child_dir_path} - removing.")
        os.remove(child_dir_path)

    # skip the dir checking
    continue

A rudimentary solution where I filter for only 'text/plain' files with exactly 1 line (since checking anything else is pointless) and trying to determine whether that single line is just a file path (this seems excessive though):

# Check if Git downloaded the symlink as a plain text file (undetectable broken symlink)
if not os.path.isdir(child_dir_path):
    try:
        if magic.Magic(mime = True, uncompress = True).from_file(child_dir_path) == 'text/plain':
            with open(child_dir_path, 'r') as file:
                for i, line in enumerate(file):
                    if i >= 1:
                        raise StopIteration
                else:
                    # this function is directly copied from https://stackoverflow.com/a/34102855/8705841
                    if is_path_exists_or_creatable(line):
                        print(f"-- Found broken Git link file '{child_dir_path}' - removing.")
                        print(f"\tContents: \"{line}\"")
                        # os.remove(child_dir_path)
                        raise StopIteration
    except (StopIteration, UnicodeDecodeError, magic.MagicException):
        file.close()
        continue

Clearly this solution would require a lot of refactoring (9 indents is pretty ridiculous) if it's the only viable option. Problem with this solution (currently) is that it also tries to delete any single-line files with a string that does not break pathname requirements- i.e. import _virtualenv, some random test string, project-name. Filtering out those files with spaces, or files without slashes, could potentially work but this still feels like chasing edge cases instead of solving the actual problem.

I could potentially rewrite this script in Bash wherein I could, in addition to existing symlink search/destroy code, parse the results from git ls-files -s ... and then delete any files with the 120000 tag. But is this method feasible and/or reliable? There should be a way to do this from within Python since Bash isn't going to run on every OS.

Note: file names have been redacted/changed after copy-paste for privacy, they shouldn't matter anyways since they are generated dynamically by the path searching functions


问:
pgAdmin tables not refreshing
I've created 4 tables in query tool but the tables are not listed under schema.

Tables are returned successfully & I've refreshed everything several times. I'm super new to this, what am I missing? As easy-to-explain as possible, thanks in advance.

Screenshot of issue

Title: pgAdmin tables not refreshing


问:
Problem with packaging Spring Boot with React
I was following this article and this video to package frontend and backend into one jar. Build is successful, but when I go to localhost:8080 instead of react app I see responses from backend, for example jsons from get requests or thymeleaf pages I used before react.

I tried to follow both sources mentioned previously and several answers on Stackoverflow, but nothing seems to help. I'm new to this and I don't really know what should I check more.

Project structure

pom.xml

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.1</version>
        <relativePath/>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>FilmLib</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>FilmLib</name>
    <description>FilmLib</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <!--Thymeleaf-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <!--Bootstrap-->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>5.2.3</version>
        </dependency>

        <!--Database-->
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>6.1.5.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>8.0.0.Final</version>
        </dependency>

        <!--Security-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>

        <!--JWT-->
        <dependency>
            <groupId>com.auth0</groupId>
            <artifactId>java-jwt</artifactId>
            <version>4.2.1</version>
        </dependency>

        <!--Misc-->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>31.1-jre</version>
        </dependency>

        <!--Test-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.12.1</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.project-lombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>

            <!--Method #2-->
            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.12.1</version>
                <configuration>
                    <workingDirectory>src/frontend</workingDirectory>
                    <installDirectory>target</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v16.17.0</nodeVersion>
                            <npmVersion>8.19.2</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <configuration>
                            <target>
                                <copy todir="${project.build.directory}/classes/public">
                                    <fileset dir="${project.basedir}/src/frontend"/>
                                </copy>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
</code>```

package.json

```<code>{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@reduxjs/toolkit": "^1.9.1",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^14.4.3",
    "axios": "^1.2.1",
    "bootstrap": "^5.2.3",
    "react": "^18.2.0",
    "react-bootstrap": "^2.6.0",
    "react-dom": "^18.2.0",
    "react-redux": "^8.0.5",
    "react-router-dom": "^6.4.4",
    "react-scripts": "5.0.1",
    "web-vitals": "^3.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "proxy": "http://localhost:8080/api"
}
</code>```

Body:
I was following this article and this video to package frontend and backend into one jar. Build is successful, but when I go to localhost:8080 instead of react app I see responses from backend, for example jsons from get requests or thymeleaf pages I used before react.

I tried to follow both sources mentioned previously and several answers on Stackoverflow, but nothing seems to help. I'm new to this and I don't really know what should I check more.

Project structure

pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.1</version>
        <relativePath/>
    </parent>
    <groupId>com.example</groupId>
    <artifactId>FilmLib</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>FilmLib</name>
    <description>FilmLib</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>5.2.3</version>
        </dependency>

        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.hibernate.orm</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>6.1.5.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate.validator</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>8.0.0.Final</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
        </dependency>
        <dependency>
            <groupId>org.thymeleaf.extras</groupId>
            <artifactId>thymeleaf-extras-springsecurity5</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>com.auth0</groupId>
            <artifactId>java-jwt</artifactId>
            <version>4.2.1</version>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>31.1-jre</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-test</artifactId>
        <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-antrun-plugin</artifactId>
            <version>3.1.0</version>
        </dependency>

        <dependency>
            <groupId>com.github.eirslett</groupId>
            <artifactId>frontend-maven-plugin</artifactId>
            <version>1.12.1</version>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.project-lombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.eirslett</groupId>
                <artifactId>frontend-maven-plugin</artifactId>
                <version>1.12.1</version>
                <configuration>
                    <workingDirectory>src/frontend</workingDirectory>
                    <installDirectory>target</installDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>install node and npm</id>
                        <goals>
                            <goal>install-node-and-npm</goal>
                        </goals>
                        <configuration>
                            <nodeVersion>v16.17.0</nodeVersion>
                            <npmVersion>8.19.2</npmVersion>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm install</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>install</arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>npm run build</id>
                        <goals>
                            <goal>npm</goal>
                        </goals>
                        <configuration>
                            <arguments>run build</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>generate-resources</phase>
                        <configuration>
                            <target>
                                <copy todir="${project.build.directory}/classes/public">
                                    <fileset dir="${project.basedir}/src/frontend"/>
                                </copy>
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

package.json

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@reduxjs/toolkit": "^1.9.1",
    "@testing-library/jest-dom": "^5.16.5",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^14.4.3",
    "axios": "^1.2.1",
    "bootstrap": "^5.2.3",
    "react": "^18.2.0",
    "react-bootstrap": "^2.6.0",
    "react-dom": "^18.2.0",
    "react-redux": "^8.0.5",
    "react-router-dom": "^6.4.4",
    "react-scripts": "5.0.1",
    "web-vitals": "^3.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "proxy": "http://localhost:8080/api"
}


问:
Experiencing weird problem when deploying node app
I am trying to deploy my node project to render.com but when I do it I get the following output

```<code>Dec 23 01:21:18 AM  sh: 1: react-app-rewired: not found
Dec 23 01:21:18 AM  npm ERR! code ELIFECYCLE
Dec 23 01:21:18 AM  npm ERR! syscall spawn
Dec 23 01:21:18 AM  npm ERR! file sh
Dec 23 01:21:18 AM  npm ERR! errno ENOENT
Dec 23 01:21:18 AM  npm ERR! openai-template@1.0.0 build: `react-app-rewired build`
Dec 23 01:21:18 AM  npm ERR! spawn ENOENT
Dec 23 01:21:18 AM  npm ERR!
Dec 23 01:21:18 AM  npm ERR! Failed at the openai-template@1.0.0 build script.
Dec 23 01:21:18 AM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Dec 23 01:21:18 AM
Dec 23 01:21:18 AM  npm ERR! A complete log of this run can be found in:
Dec 23 01:21:18 AM  npm ERR!     /opt/render/.cache/_logs/2022-12-23T00_21_18_486Z-debug.log
Dec 23 01:21:18 AM  ==> Build failed
</code>```

It seems as it can't find react-app-rewired but I have it installed in my node-modules. Does anyone have a solution that might help?

Body:
I am trying to deploy my node project to render.com but when I do it I get the following output

Dec 23 01:21:18 AM  sh: 1: react-app-rewired: not found
Dec 23 01:21:18 AM  npm ERR! code ELIFECYCLE
Dec 23 01:21:18 AM  npm ERR! syscall spawn
Dec 23 01:21:18 AM  npm ERR! file sh
Dec 23 01:21:18 AM  npm ERR! errno ENOENT
Dec 23 01:21:18 AM  npm ERR! openai-template@1.0.0 build: `react-app-rewired build`
Dec 23 01:21:18 AM  npm ERR! spawn ENOENT
Dec 23 01:21:18 AM  npm ERR!
Dec 23 01:21:18 AM  npm ERR! Failed at the openai-template@1.0.0 build script.
Dec 23 01:21:18 AM  npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Dec 23 01:21:18 AM
Dec 23 01:21:18 AM  npm ERR! A complete log of this run can be found in:
Dec 23 01:21:18 AM  npm ERR!     /opt/render/.cache/_logs/2022-12-23T00_21_18_486Z-debug.log
Dec 23 01:21:18 AM  ==> Build failed

It seems as it can't find react-app-rewired but I have it installed in my node-modules. Does anyone have a solution that might help?


问:
Prestashop admin login error 302, CloudFlare and LiteSpeed server

We have migrated a PrestaShop(PS) v.1.7.8.7 from an Apache server to a LiteSpeed server which includes the LiteSpeed cache module for PS and crawler enabled.

CloudFlare(CF) has always been in play with both the existing and the new server.

But when we enable "proxied" in DNS settings for the new server - then we suddenly can't login at the admin URL due to a 302 error. It looks like the login page is called 2 times in a row. All other functionality on the site works flawless.

Screenshots of the main-domain which is "proxied" via CF:

When we disable "proxied" in CF then we can login via the PS Admin page again as seen in the screenshot below:

Screenshot of the test-domain which is not "proxied" via CF:

The page just redirects to itself again and doesn't complain about wrong user credentials or similar.

We believe it's due to Litespeed's re-write logic. We have tried to disable the LiteSpeed cache module again (the LiteSpeed's rewrite rules are of course still unchanged even though the cache module has been disabled in PS) - and the issue remains. Somehow there is a conflict between CF and LiteSpeed in this setup which causes the redirect error. We know that WordPress has a CF module which enables CF and LiteSpeed's cache module to work simultaneously.


问:
How to access event listeners of element using Selenium?
I'm writing a web scraper using Selenium/Python, and I need to access and call the onclick handler of a specific element using execute_script. Seems the event listener is set via addEventListener() rather than assign the onclick property of the element, so the onclick property of the element is null.

I can easily access the handler at Chrome Developer Console using the getEventListeners function, but since the function is limited to Chrome DevTools Console, I can't use it when I call Selenium execute_script(See here). Is it a way that I can do this?


问:
Can not import pyi file
The file structure is like this

```<code>project
--idl
    --__init__.py
    --a.thrift
    --a_thrift.pyi
    --b.py

--main.py
</code>```

in main.py, there is sth like

```<code>from idl.a_thrift import xxx
</code>```

when running python main.py,
it will complain about

```<code>ModuleNotFoundError: No module named idl.a_thrift
</code>```

However, main.py can import the module from idl.b

I have set PYTHONPATH to the project directory.
Any idea what's wrong with it?

Title: Can not import pyi file

Body:
The file structure is like this

project
--idl
    --__init__.py
    --a.thrift
    --a_thrift.pyi
    --b.py

--main.py

in main.py, there is sth like

from idl.a_thrift import xxx

when running python main.py,
it will complain about

ModuleNotFoundError: No module named idl.a_thrift

However, main.py can import the module from idl.b

I have set PYTHONPATH to the project directory.
Any idea what's wrong with it?


问:
bedrock-wordpress-sage-docker installation problem
I'm a newbie on wordpress development. I'm trying to install a project with bedrock/wordpress/sage to customize a website.

I have some difficulties to make that work.

Could you please help me? Thanks.

Here is my .env file

```<code># DB_NAME='database_name'
# DB_USER='database_user'
# DB_PASSWORD='database_password'
DATABASE_URL=mysql://admin:admin@wordpress-db:3306/wordpress

# Optionally, you can use a data source name (DSN)
# When using a DSN, you can remove the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST variables
# DATABASE_URL='mysql://database_user:database_password@database_host:database_port/database_name'

# Optional database variables
# DB_HOST='localhost'
# DB_PREFIX='wp_'

WP_ENV='development'
WP_HOME='localhost'
WP_SITEURL="${WP_HOME}/wp"

# Specify optional debug.log path
# WP_DEBUG_LOG='/path/to/debug.log'

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='Lvsbw<?[Dl=p+uL/f=Vdi8+ers;=.Nv|<x}.;+kkycB%,@T9mG*e8x=1PTX&sHau'
SECURE_AUTH_KEY='rc,.Jojid!@XH$}oQmg1K7pAfY!i:JBCG}/tK=F;-n*bz-h_jH4,?&n`?$FIRJ(<'
LOGGED_IN_KEY='Gef3q;/]}S>o7OQ01C)3aIX.z.=Q}i=X+ibp&edsX;=.1.30ADStU`p5i@hp`u%B'
NONCE_KEY='#B|@)JeAA9A4j5rQ<Nr|@vLTu?Ep7*M27$,MbQTR6$J{<<Q9(!H:;Tx]hJRtb0x7'
AUTH_SALT='}At#EaRyj|tEPn_P:03bH@&v4YDfXz3z}O$BoOo[6iyn{6WV@HX4:,IYru!TvUFE'
SECURE_AUTH_SALT='#.J]K1LeO6]ziAdO[)HIKaX(Oi><*#hib4yU!O7M@M?hPEtpmn+J:Cu#gMj[uXgq'
LOGGED_IN_SALT='ns*hcTcdL)Z:9cYl%r0<W`[sA1GI`dakv}(jD@$/c-Pid%DmaKU]u#L%D*yv>bn('
NONCE_SALT='#6^Ed-pn65e[nv0FCH5yT%k5oSR*neyfu)ha,-dg)Pa,VT*Py3w}AE]#H<.3A)tz'
</code>```

located on the root of the bedrock folder

Here is my docker-compose.yml file for docker

  version: "3"

  services:
    # wordpress-db:
    #   image: mariadb:latest
    #   volumes:
    #     - wordpress-db-data:/var/lib/mysql
    #   restart: always
    #   environment:
    #     MYSQL_ROOT_PASSWORD: admin
    #     MYSQL_DATABASE: wordpress
    #     MYSQL_USER: admin
    #     MYSQL_PASSWORD: admin
    #   container_name: wordpress-db
    #   ports:
    #     - '3306:3306'

    wordpress-db:
      image: mysql:5.7
      volumes:
        - wordpress-db-data:/var/lib/mysql
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: admin
        MYSQL_DATABASE: wordpress
        MYSQL_USER: admin
        MYSQL_PASSWORD: admin
      container_name: wordpress-db
      ports:
        - '3306:3306'

    phpmyadmin:
      depends_on:
        - wordpress-db
      image: phpmyadmin/phpmyadmin
      restart: always
      ports:
        - '7555:80'

    wordpress-wp:
      depends_on:
        - wordpress-db
      image: wordpress:latest
      links:
        - wordpress-db
      volumes:
        - ./web:/var/www/html
        - ./config:/var/www/config
        - ./vendor:/var/www/vendor
        - ./.env:/var/www/.env
        - ./composer.json:/var/www/composer.json
        - ./wp-cli.yml:/var/www/wp-cli.yml
      ports:
      - '80:80'
      restart: always
      container_name: wordpress-wp
  volumes:
    wordpress-db-data:
      driver: local
```
<p>My bud config on sage</p>
```// @ts-check

/**
 * Build configuration
 *
 * @see {@link https://bud.js.org/guides/configure}
 * @param {import('@roots/bud').Bud} app
 */
export default async (app) => {
  app
    /**
     * Application entrypoints
     */
    .entry({
      app: ["@scripts/app", "@styles/app"],
      editor: ["@scripts/editor", "@styles/editor"],
    })

    /**
     * Directory contents to be included in the compilation
     */
    .assets(["images"])

    /**
     * Matched files trigger a page reload when modified
     */
    .watch(["resources/views/**/*", "app/**/*"])

    /**
     * Proxy origin (`WP_HOME`)
     */
    .proxy("http://localhost/wp")

    /**
     * Development origin
     */
    .serve("http://localhost")

    /**
     * URI of the `public` directory
     */
    .setPublicPath("/app/themes/pasto-theme/public/")

    /**
     * Generate WordPress `theme.json`
     *
     * @note This overwrites `theme.json` on every build.
     */
    .wpjson
      .settings({
        color: {
          custom: false,
          customGradient: false,
          defaultPalette: false,
          defaultGradients: false,
        },
        custom: {
          spacing: {},
          typography: {
            'font-size': {},
            'line-height': {},
          },
        },
        spacing: {
          padding: true,
          units: ['px', '%', 'em', 'rem', 'vw', 'vh'],
        },
        typography: {
          customFontSize: false,
        },
      })
      .useTailwindColors()
      .useTailwindFontFamily()
      .useTailwindFontSize()
      .enable()
};
```

I have routing problems, some prefixes appear twice on the url and unfortunately I can't access to my database via phpmyadmin.

Thanks for your help.

Body:
I'm a newbie on wordpress development. I'm trying to install a project with bedrock/wordpress/sage to customize a website.

I have some difficulties to make that work.

Could you please help me? Thanks.

Here is my .env file

# DB_NAME='database_name'
# DB_USER='database_user'
# DB_PASSWORD='database_password'
DATABASE_URL=mysql://admin:admin@wordpress-db:3306/wordpress

# Optionally, you can use a data source name (DSN)
# When using a DSN, you can remove the DB_NAME, DB_USER, DB_PASSWORD, and DB_HOST variables
# DATABASE_URL='mysql://database_user:database_password@database_host:database_port/database_name'

# Optional database variables
# DB_HOST='localhost'
# DB_PREFIX='wp_'

WP_ENV='development'
WP_HOME='localhost'
WP_SITEURL="${WP_HOME}/wp"

# Specify optional debug.log path
# WP_DEBUG_LOG='/path/to/debug.log'

# Generate your keys here: https://roots.io/salts.html
AUTH_KEY='Lvsbw<?[Dl=p+uL/f=Vdi8+ers;=.Nv|<x}.;+kkycB%,@T9mG*e8x=1PTX&sHau'
SECURE_AUTH_KEY='rc,.Jojid!@XH$}oQmg1K7pAfY!i:JBCG}/tK=F;-n*bz-h_jH4,?&n`?$FIRJ(<'
LOGGED_IN_KEY='Gef3q;/]}S>o7OQ01C)3aIX.z.=Q}i=X+ibp&edsX;=.1.30ADStU`p5i@hp`u%B'
NONCE_KEY='#B|@)JeAA9A4j5rQ<Nr|@vLTu?Ep7*M27$,MbQTR6$J{<<Q9(!H:;Tx]hJRtb0x7'
AUTH_SALT='}At#EaRyj|tEPn_P:03bH@&v4YDfXz3z}O$BoOo[6iyn{6WV@HX4:,IYru!TvUFE'
SECURE_AUTH_SALT='#.J]K1LeO6]ziAdO[)HIKaX(Oi><*#hib4yU!O7M@M?hPEtpmn+J:Cu#gMj[uXgq'
LOGGED_IN_SALT='ns*hcTcdL)Z:9cYl%r0<W`[sA1GI`dakv}(jD@$/c-Pid%DmaKU]u#L%D*yv>bn('
NONCE_SALT='#6^Ed-pn65e[nv0FCH5yT%k5oSR*neyfu)ha,-dg)Pa,VT*Py3w}AE]#H<.3A)tz'

located on the root of the bedrock folder

Here is my docker-compose.yml file for docker

  version: "3"

  services:
    # wordpress-db:
    #   image: mariadb:latest
    #   volumes:
    #     - wordpress-db-data:/var/lib/mysql
    #   restart: always
    #   environment:
    #     MYSQL_ROOT_PASSWORD: admin
    #     MYSQL_DATABASE: wordpress
    #     MYSQL_USER: admin
    #     MYSQL_PASSWORD: admin
    #   container_name: wordpress-db
    #   ports:
    #     - '3306:3306'

    wordpress-db:
      image: mysql:5.7
      volumes:
        - wordpress-db-data:/var/lib/mysql
      restart: always
      environment:
        MYSQL_ROOT_PASSWORD: admin
        MYSQL_DATABASE: wordpress
        MYSQL_USER: admin
        MYSQL_PASSWORD: admin
      container_name: wordpress-db
      ports:
        - '3306:3306'

    phpmyadmin:
      depends_on:
        - wordpress-db
      image: phpmyadmin/phpmyadmin
      restart: always
      ports:
        - '7555:80'

    wordpress-wp:
      depends_on:
        - wordpress-db
      image: wordpress:latest
      links:
        - wordpress-db
      volumes:
        - ./web:/var/www/html
        - ./config:/var/www/config
        - ./vendor:/var/www/vendor
        - ./.env:/var/www/.env
        - ./composer.json:/var/www/composer.json
        - ./wp-cli.yml:/var/www/wp-cli.yml
      ports:
      - '80:80'
      restart: always
      container_name: wordpress-wp
  volumes:
    wordpress-db-data:
      driver: local

My bud config on sage

// @ts-check

/**
 * Build configuration
 *
 * @see {@link https://bud.js.org/guides/configure}
 * @param {import('@roots/bud').Bud} app
 */
export default async (app) => {
  app
    /**
     * Application entrypoints
     */
    .entry({
      app: ["@scripts/app", "@styles/app"],
      editor: ["@scripts/editor", "@styles/editor"],
    })

    /**
     * Directory contents to be included in the compilation
     */
    .assets(["images"])

    /**
     * Matched files trigger a page reload when modified
     */
    .watch(["resources/views/**/*", "app/**/*"])

    /**
     * Proxy origin (`WP_HOME`)
     */
    .proxy("http://localhost/wp")

    /**
     * Development origin
     */
    .serve("http://localhost")

    /**
     * URI of the `public` directory
     */
    .setPublicPath("/app/themes/pasto-theme/public/")

    /**
     * Generate WordPress `theme.json`
     *
     * @note This overwrites `theme.json` on every build.
     */
    .wpjson
      .settings({
        color: {
          custom: false,
          customGradient: false,
          defaultPalette: false,
          defaultGradients: false,
        },
        custom: {
          spacing: {},
          typography: {
            'font-size': {},
            'line-height': {},
          },
        },
        spacing: {
          padding: true,
          units: ['px', '%', 'em', 'rem', 'vw', 'vh'],
        },
        typography: {
          customFontSize: false,
        },
      })
      .useTailwindColors()
      .useTailwindFontFamily()
      .useTailwindFontSize()
      .enable()
};

I have routing problems, some prefixes appear twice on the url and unfortunately I can't access to my database via phpmyadmin.

Thanks for your help.


问:
Discord.py 2.0 warning system - Slash Commands
With the new slash commands I was writing out a new warning system for it but it doesn't seem to work and the console isn't giving me any errors. Does anyone know what I did wrong in my code?

async def addwarn(interaction: discord.Interaction, reason, user):
    db = sqlite3.connect("warning.sqlite")
    cursor = db.cursor()
    cursor.execute("INSERT INTO warns (user, reason, time, guild) VALUES (?, ?, ?, ?)", (user.id, reason, int(datetime.now().timestamp()), interaction.guild.id))
    db.commit()

@bot.tree.command(name='warn', description='Warns the member selected') # warn slash command
@app_commands.checks.has_permissions(kick_members=True)
async def warn(interaction: discord.Interaction, member: discord.Member, *, reason:str = "No reason given"):
    await addwarn(interaction, reason, member)
    embed = discord.Embed(title=f"Warned {member}\nReason: {reason}", color=0x32CD32)
    await interaction.response.send_message(embed=embed, ephemeral=True)

@bot.tree.command(name='delwarn', description='deletes all warns from the member selected') # delete warn slash command
@app_commands.checks.has_permissions(kick_members=True)
async def delwarn(interaction: discord.Interaction, member: discord.Member):
    db = sqlite3.connect("warning.sqlite")
    cursor = db.cursor()
    cursor.execute("SELECT reason FROM warns WHERE user = ? AND guild = ?", (member.id, interaction.guild.id))
    data = cursor.fetchone()
    if data:
        cursor.execute("DELETE FROM warns WHERE user = ? AND guild = ?", (member.id, interaction.guild.id))
        embed = discord.Embed(title=f"Removed all warns from {member}", color=0x32CD32)
        await interaction.response.send_message(embed=embed, ephemeral=True)
    else:
        embed = discord.Embed(title=f"{member} has no warnings to remove.", color=0x32CD32)
        await interaction.response.send_message(embed=embed, ephemeral=True)
    db.commit()
```

Please don't tell me it was a simple miss spell because if it is imma be sad.

Here is what Discord says when I try using the commands:

If you need anymore details please feel free to ask.

Body:
With the new slash commands I was writing out a new warning system for it but it doesn't seem to work and the console isn't giving me any errors. Does anyone know what I did wrong in my code?

async def addwarn(interaction: discord.Interaction, reason, user):
    db = sqlite3.connect("warning.sqlite")
    cursor = db.cursor()
    cursor.execute("INSERT INTO warns (user, reason, time, guild) VALUES (?, ?, ?, ?)", (user.id, reason, int(datetime.now().timestamp()), interaction.guild.id))
    db.commit()

@bot.tree.command(name='warn', description='Warns the member selected') # warn slash command
@app_commands.checks.has_permissions(kick_members=True)
async def warn(interaction: discord.Interaction, member: discord.Member, *, reason:str = "No reason given"):
    await addwarn(interaction, reason, member)
    embed = discord.Embed(title=f"Warned {member}\nReason: {reason}", color=0x32CD32)
    await interaction.response.send_message(embed=embed, ephemeral=True)

@bot.tree.command(name='delwarn', description='deletes all warns from the member selected') # delete warn slash command
@app_commands.checks.has_permissions(kick_members=True)
async def delwarn(interaction: discord.Interaction, member: discord.Member):
    db = sqlite3.connect("warning.sqlite")
    cursor = db.cursor()
    cursor.execute("SELECT reason FROM warns WHERE user = ? AND guild = ?", (member.id, interaction.guild.id))
    data = cursor.fetchone()
    if data:
        cursor.execute("DELETE FROM warns WHERE user = ? AND guild = ?", (member.id, interaction.guild.id))
        embed = discord.Embed(title=f"Removed all warns from {member}", color=0x32CD32)
        await interaction.response.send_message(embed=embed, ephemeral=True)
    else:
        embed = discord.Embed(title=f"{member} has no warnings to remove.", color=0x32CD32)
        await interaction.response.send_message(embed=embed, ephemeral=True)
    db.commit()

Please don't tell me it was a simple miss spell because if it is imma be sad.

Here is what Discord says when I try using the commands:

If you need anymore details please feel free to ask.