python – How to save screen output into a text file

So I need to create a script and save the info into a text file, and here is what I did:

import platform

def bios_version():

    uname_result = platform.uname()

    pl = {}

    pl('BIOS version') = uname_result.version

    for a, b in pl.items():

        print(a, ":", b)


print(bios_version())

save_path = 'D:/'

name_of_file = input("What is the name of the file: ")

completeName = os.path.join(save_path, name_of_file+".txt")

f = open(completeName, "w")

f.write(bios_version())

f.close

So it return:
f.write(bios_version())
TypeError: write() argument must be str, not None”

If i save a youtube video as "draft" and then i set it to "public", will the notifications be sent correctly?

I left a video as a draft today, and tomorrow I will leave it as "public"

magento2 – Can’t Save Categories Magento 2.3.5-p1

So i cannot save categories and attempting to do so produces below error in system.log:

    (2021-04-15 16:16:30) main.CRITICAL: Error: Call to a member function getAttributeCode() on bool in /home/sites/buzzcateringsupplies.com/public_html/vendor/magento/module-catalog/Observer/InvalidateCacheOnCategoryDesignChange.php:67
    Stack trace:
    #0 /home/sites/magento/public_html/vendor/magento/framework/Event/Invoker/InvokerDefault.php(88): MagentoCatalogObserverInvalidateCacheOnCategoryDesignChange->execute(Object(MagentoFrameworkEventObserver))
    ...
    ...

Strange as seems to work in my dev environment so seems some update have not occured in live database when running setup upgrade. I notice that my custom layout update attribute is empty like below:

enter image description here

So i am assuming there are potentially a few things wrong here.

Other solutions suggest running queries like below in to database:

INSERT INTO `eav_attribute` (`entity_type_id`, `attribute_code`, `attribute_model`, `backend_model`, `backend_type`, `backend_table`, `frontend_model`, `frontend_input`, `frontend_label`, `frontend_class`, `source_model`, `is_required`, `is_user_defined`, `default_value`, `is_unique`, `note`) VALUES

(4, 'custom_layout_update_file', NULL, 'Magento\Catalog\Model\Product\Attribute\Backend\LayoutUpdate', 'varchar', NULL, NULL, 'select', 'Custom Layout Update', NULL, 'Magento\Catalog\Model\Product\Attribute\Source\LayoutUpdate', 0, 0, NULL, 0, NULL),
(3, 'custom_layout_update_file', NULL, 'Magento\Catalog\Model\Category\Attribute\Backend\LayoutUpdate', 'varchar', NULL, NULL, 'select', 'Custom Layout Update', NULL, 'Magento\Catalog\Model\Category\Attribute\Source\LayoutUpdate', 0, 0, NULL, 0, NULL);

However not a big fan and would like to get to bottom of why this update has not run. The above does actually allow saving of categories however the dropdown is still empty. I’m also confused as thought in 2.3.4 and above the Layout update XML field should no longer be present…

Have searched around and cannot see a solution or explanation and hoping someone might be able to point me in the right direction. Have tried a few DB imports and updates since however same thing happens.

dnd 5e – Does the 3rd benefit of the (UA) Fizban’s Platinum Shield spell stack with Evasion, so that the character only takes 1/4 damage on a failed Dex save?

The new UA, Unearthed Arcana: Draconic Options, introduces a 6th-level spell called Fizban’s platinum shield that can be cast on a creature within 60 feet of the caster, granting them a few benefits. The description of the final benefit reads as follows:

  • If the creature is subjected to an effect that allows it to make a Dexterity saving throw to take only half damage, the creature instead takes no damage if it succeeds on the saving throw, and only half damage if it fails.

This has the same effect as the Evasion feature of a Monk or Rogue (or Hunter ranger, maybe).

Since this spell benefit and Evasion have the same effect but different names from different sources, would they stack with each other?
For instance, in the case of a 7th-level monk failing a Dex save against the fireball spell while under the effect of this spell, would they take a quarter damage?

front end – How to programmatically save tagged cells from currently open notebook (nb ext) as a package file (m ext)?

Please do not tag this question as already answered because the method described at Is there a way to programmatically do a “save as ” on an init.nb file to save it as init.m? no longer works.

I often need to make edits to an init.m file which I have saved in two locations (FrontEnd,Kernel) in the $UserBaseDirectory. Doing this manually becomes quite cumbersome so I am looking for a quick and easy programmatically way of doing this.

I do all edits on init.nb and then do a Save As init.m to the two aforementioned locations. Ideally I only wish to save tagged cells from the currently open notebook (init.nb). Unfortunately I am very new to programmatic notebook operations so I am having great difficulty figuring this out.

As a proof of concept I wish to save the full contents of a list of tagged cells to a given temporary directory dir.

cells = Cells(CellTags -> {"paths", "packs", "tasks"})
dir = FileNameJoin({$Home, "tmp"})
file= FileNameJoin({dir, "tmp.m"})

Although the following would have saved the entire contents of my notebook it did not work…

FrontEndTokenExecute(
 FrontEnd`InputNotebook(), "SaveRename", {file, "Package"})

I also tried this…

FrontEndTokenExecute(
 FrontEnd`EvaluationNotebook(), "SaveRename", {file, "Package"})

Please help. I tried many different things shown in official documentation and did learn a lot unfortunately nothing that addresses this problem.

dnd 5e – Can someone who fails the save against a Zone of Truth spell lie non-vocally?

By RAW, you can lie non vocally in a Zone of Truth.

The Zone guards against deception. PHB page 178 states

Your Charisma (Deception) check determines whether you can convincingly hide the truth, either verbally or through your actions.

In the spell description of Zone of Truth, they are not referring to Deception the skill, but the definition of the skill lines up fairly well with the english language definition, which states that deception is the act of decieving someone, and decieve is defined as making someone believe something that is not true, with no mention of having to speak.

This means deception does not have to be vocal, or even verbal. However, there is some ambiguity.
You cannot speak a deliberate lie. Speaking clearly means talking, making a sound with your voice in a certain language. Body language, sign language, and pantomime are not speaking.

By RAI, you cannot lie non vocally in a Zone of Truth.

They say speak a deliberate lie, yes, and RAW must interpret every word of the spell description. However, it seems obvious to me that they intended no deception to be possible, as shown in the earlier line.

spells – Can Saving Finale be used to save another creature from Phantasmal Killer?

The bard spell Saving Finale lets the bard end his performance to let one of the performance’s targets reroll a failed save:

DESCRIPTION

You must have a bardic performance in effect to cast this spell. With
a flourish, you can immediately end your bardic performance when a
creature within range affected by your bardic performance fails a
Saving Throw, allowing the subject to immediately reroll the failed
Saving Throw.

The question is, how does the bard know that the creature that he wants to help has failed a save? Phantasmal Killer reads:

DESCRIPTION

You create a phantasmal image of the most fearsome creature imaginable
to the subject simply by forming the fears of the subject’s
subconscious mind into something that its conscious mind can
visualize: this most horrible beast. Only the spell’s subject can see
the phantasmal killer. You see only a vague shape. The target first
gets a Will save to recognize the image as unreal. If that save fails,
the phantasm touches the subject, and the subject must succeed on a
Fortitude save or die from fear.
Even if the Fortitude save is
successful, the subject takes 3d6 points of damage.

If the subject of a phantasmal killer attack succeeds in disbelieving
and possesses telepathy or is wearing a helm of telepathy, the beast
can be turned upon you. You must then disbelieve it or become subject
to its deadly fear attack.

Since only the subject can see the phantasmal killer, if the bard fails his Spellcraft roll to identify what the enemy is casting, does he miss the chance to save his ally?

java – Architectural problem for class combination (cartesian product) for save format strategy

Hello to everyone and thank you for any suggestion.

I have a family of subclasses of Track (Track is abstract).
Every concrete Track has a different number and types of fields (attributes) that extend the basic abstract track-fields.

Then I have a family of file-types that implement some methods (saveRow() etc..).
Every file is presumed to have different type of row-formatting (imagine csv tabs, headers etc..)

ex:

  • SimpleTrack: double lat, double lon, Calendar dateTime.
  • DetectionTrack: (as SimpleTrack) + boolean detection.
  • ..
  • CsvFile
  • TxtFile

When I create a new (X)Track and a (Y) file, they are independent by nature, but.. the row is a cartesian product of track & row types.

EDIT
(to be more clear): How can I have many concrete-tracks in one hand and many FileTypes in the other hand, and create well-formatted-rows (differents for every file) by tracks which have different data (columns, headers..)?
es:

  • XtrackRow(double a, double b, Calendar date) -> to -> CVSfile (tab delimited with headers)
  • XtrackRow(double a, double b, Calendar date) -> to -> TXTfile (formatted columns and title)
  • YtrackRow(double a, string, b, int c, double e) -> to CSV ..
  • YtrackRow …. -> to -> docx file (with another kind of table or tabulation)
    ..

I see two kinds of solutions:

  1. Tracks send (right)-formatted row to file: every track has to know which kind of format apply (to rows) to give them to save to any specific type of file.
  2. Tracks send raw-data to any kind of file which is responsible to format them: in this case, the file-class must know wich kind of data has to format (every track has diffrent contents, columns, headers..). Moreover, every track-class has to send different number and types of parameter..

The second solution seems to be more fitted to the Single-Responsibility principle.. but I have no Idea how to implement it.

I tried to use Bridge Pattern to solve this problem (using first solution):

abstract class Track{
  ...
  FileInterface file;

  Track(FileInterface fileType){
    this.file = fileType;
  }

  abstract String formatConcreteTrackRow();
  
  void sendRow(){
    String rowToSave = formatConcreteTrackRow();
    file.saveRow(rowToSave);
  }
}

By this way the problem is not already solved, because every concrete-track has to implement a set of methods which returs right formatted rowString: one for every file-type.
If I use a Strategy Pattern:

class SimpleTrack extends Track{
  ...
  RowFormatStrategy rowStrategy;
  
  @override
  String formatConcreteTrackRow(){
    return this.rowStrategy.getRowString("args")
}

but in this case.. every concrete-track require a different StrategyInterface, because every concrete-track has different number and types of arguments to elaborate..
If I do not use Strategy Pattern and I define a set of methods (formatCsvRow(args),formatTxtRow(args)..) I need to include a switch(fileType) loop to choose which method to use.. breaking SOLID principles.. 🙁

Moreover..
how to impose, for every new concrete-track to have right row-format methods for every existent file-template-row?
and.. How to impose, at the same time, for every new file-class to impose new templates and relative methods in every existent concrete-track?

To be honest, it’s also quite reductive impose formatConcreteTrackRow to be a String, but it’s over and over the main problem.

I’m not interested to maintain this kind of class structure, this is only the best solution I found trying to follow SOLID principles. If you can show me a better solution, my intent is to study and understand SOLID procedures to solve these kind of purposes.

(I looked around for similar questions, but I’m not even able to define the specific problem itself..)
Thank you very much.

java – Architettural problem for class combination (cartesian product) for save format strategy

Hello to everyone and thank you for any suggestion.

I have a family of subclasses of Track (Track is abstract).
Every concrete Track has a different number and types of fields (attributes) that extend the basic abstract track-fields.

Then I have a family of file-types that implement some methods (saveRow() etc..).
Every file is presumed to have different type of row-formatting (imagine csv tabs, headers etc..)

ex:

  • SimpleTrack: double lat, double lon, Calendar dateTime.
  • DetectionTrack: (as SimpleTrack) + boolean detection.
  • ..
  • CsvFile
  • TxtFile

When I create a new (X)Track and a (Y) file, they are independent by nature, but.. the row is a cartesian product of track & row types.

EDIT
(to be more clear): How can I have many concrete-tracks in one hand and many FileTypes in the other hand, and create well-formatted-rows (differents for every file) by tracks which have different data (columns, headers..)?
es:

  • XtrackRow(double a, double b, Calendar date) -> to -> CVSfile (tab delimited with headers)
  • XtrackRow(double a, double b, Calendar date) -> to -> TXTfile (formatted columns and title)
  • YtrackRow(double a, string, b, int c, double e) -> to CSV ..
  • YtrackRow …. -> to -> docx file (with another kind of table or tabulation)
    ..

I see two kinds of solutions:

  1. Tracks send (right)-formatted row to file: every track has to know which kind of format apply (to rows) to give them to save to any specific type of file.
  2. Tracks send raw-data to any kind of file which is responsible to format them: in this case, the file-class must know wich kind of data has to format (every track has diffrent contents, columns, headers..). Moreover, every track-class has to send different number and types of parameter..

The second solution seems to be more fitted to the Single-Responsibility principle.. but I have no Idea how to implement it.

I tried to use Bridge Pattern to solve this problem (using first solution):

abstract class Track{
  ...
  FileInterface file;

  Track(FileInterface fileType){
    this.file = fileType;
  }

  abstract String formatConcreteTrackRow();
  
  void sendRow(){
    String rowToSave = formatConcreteTrackRow();
    file.saveRow(rowToSave);
  }
}

By this way the problem is not already solved, because every concrete-track has to implement a set of methods which returs right formatted rowString: one for every file-type.
If I use a Strategy Pattern:

class SimpleTrack extends Track{
  ...
  RowFormatStrategy rowStrategy;
  
  @override
  String formatConcreteTrackRow(){
    return this.rowStrategy.getRowString("args")
}

but in this case.. every concrete-track require a different StrategyInterface, because every concrete-track has different number and types of arguments to elaborate..
If I do not use Strategy Pattern and I define a set of methods (formatCsvRow(args),formatTxtRow(args)..) I need to include a switch(fileType) loop to choose which method to use.. breaking SOLID principles.. 🙁

Moreover..
how to impose, for every new concrete-track to have right row-format methods for every existent file-template-row?
and.. How to impose, at the same time, for every new file-class to impose new templates and relative methods in every existent concrete-track?

To be honest, it’s also quite reductive impose formatConcreteTrackRow to be a String, but it’s over and over the main problem.

I’m not interested to maintain this kind of class structure, this is only the best solution I found trying to follow SOLID principles. If you can show me a better solution, my intent is to study and understand SOLID procedures to solve these kind of purposes.

(I looked around for similar questions, but I’m not even able to define the specific problem itself..)
Thank you very much.

java – Design pattern problem for class combination (cartesian product) for save format strategy

Hello to everyone and thank you for any suggestion.

I have a family of subclasses of Track (Track is abstract).
Every concrete Track has a different number and types of fields (attributes) that extend the basic abstract track-fields.

Then I have a family of file-types that implement some methods (saveRow() etc..).
Every file is presumed to have different type of row-formatting (imagine csv tabs, headers etc..)

ex:

  • SimpleTrack: double lat, double lon, Calendar dateTime.
  • DetectionTrack: (as SimpleTrack) + boolean detection.
  • ..
  • CsvFile
  • TxtFile

When I create a new (X)Track and a (Y) file, they are independent by nature, but.. the row is a cartesian product of track & row types.

I see two kinds of solutions:

  1. Tracks send (right)-formatted row to file: every track has to know which kind of format use to send formatted-row to a specific type of file.
  2. Tracks send raw-data to file which is responsible to format them: in this case, the file class must know wich kind of data has to format (headers, type of data..). Moreover, every track-class has to send different number and types of parameter..

The second solution seems to be more fitted to the Single-Responsibility principle.. but I have no Idea how to implement it.

I tried to use Bridge Pattern to solve this problem (using first solution):

abstract class Track{
  ...
  FileInterface file;

  Track(FileInterface fileType){
    this.file = fileType;
  }

  abstract String formatConcreteTrackRow();
  
  void sendRow(){
    String rowToSave = formatConcreteTrackRow();
    file.saveRow(rowToSave);
  }
}

By this way the problem is not already solved, because every concrete-track has to implement a set of methods which returs right formatted rowString: one for every file-type.
If I use a Strategy Pattern:

class SimpleTrack extends Track{
  ...
  RowFormatStrategy rowStrategy;
  
  @override
  String formatConcreteTrackRow(){
    return this.rowStrategy.getRowString("args")
}

but in this case.. every concrete-track require a different StrategyInterface, because every concrete-track has different number and types of arguments to elaborate..
If I do not use Strategy Pattern and I define a set of methods (formatCsvRow(args),formatTxtRow(args)..) I need to include a switch(fileType) loop to choose which method to use.. breaking SOLID principles.. 🙁

Moreover..
how to impose, for every new concrete-track to have right row-format methods for every existent file-template-row?
and.. How to impose, at the same time, for every new file-class to impose new templates and relative methods in every existent concrete-track?

To be honest, it’s also quite reductive impose formatConcreteTrackRow to be a String, but it’s over and over the main problem.

I’m not interested to maintain this kind of class structure, this is only the best solution I found trying to follow SOLID principles. If you can show me a better solution, my intent is to study and understand SOLID procedures to solve these kind of purposes.

(I looked around for similar questions, but I’m not even able to define the specific problem itself..)
Thank you very much.