question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Recognizing macOS Platform

See original GitHub issue

The code that determines the platform (in _utility.platform.py) doesn’t work for macOS, and it doesn’t work for most flavors of Unix:

def platform(): # the platform (eg: linux) you are using plotext with
    platform = sys.platform
    names = ["win", "linux", "unix"]
    platforms = ["windows", "linux", "unix"]
    for i in range(3):
        if names[i] in platform:
            return platforms[i]
    return "not found"

On macOS, platform is "darwin", which contains "win" and therefore gets labeled “windows”.

I recommend rewriting that function to:

def platform(): # the platform (eg: linux) you are using plotext with
    platform = sys.platform
    # According to the docs, this returns one of: 'aix', 'linux', 'win32', 'cygwin', 
    # 'darwin', or the modified result of `uname -s` on other Unix systems.
    if platform in {'win32', 'cygwin'}:
        # These are the only two possible outputs on Windows systems
        return 'windows'
    else:
        # Anything that is not Windows and that runs Python is a flavor of Unix
        return 'unix'

Since you only ever check this value for Windows, I see no benefit in making a distinction between flavors of Unix. If you do want to make that distinction, why not just return the value of sys.platform for Unix systems?

Similarly, your function _utility.platform.shell() returns "cmd" in any shell that is not Bash. On macOS, the new default is Zsh (which may people use on Linux too), and I’m sure there are people out there still using Csh and even Ksh. But it looks like this value is never actually used anywhere, so I guess it doesn’t matter.

I won’t submit a pull request, because this repository seems to have erased all its history. If you want people to contribute code, you should not do that.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
crisluengocommented, Nov 13, 2021

@piccolomo A colleague of mine recently evaluated a bunch of git courses for our team members. He recommended this (free) course on Udacity: https://www.udacity.com/course/version-control-with-git--ud123 He thought it would take maybe 10 hours to go all the way through it. If you take a bit of time every day, in no time you should understand one of the most important software development tools we have today.

in short:

  • git add . stages all changes in the current directory and subdirectories for commit.
  • git commit makes the commit.
  • git push pushes the changes to the remote server.

if you need to do git push -f you’re doing it wrong. -f tells git to overwrite things on the remote repository. It should be used only in extreme circumstances. In fact, I think by default GitHub protects the master branch, disallowing this -f action. Because it doesn’t only hide other peoples’ contributions, but it also invalidates links and commit references other people might be using.

0reactions
piccolomocommented, Dec 10, 2021

Hi @crisluengo,

I reply now to the original issue report. I should have sorted this in the newly updated 4.1.0 version, available on github and pypi.

I have removed the shell function and updated the platform function to your version.

Please let me know if the issue persists.

Thanks also for the git hub guidance! P.S. @Dev-iL, @ethack If you are still up for restoring the GitHub history, I may need the exact terminal commands.

Thanks and all the best, Savino.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Boot modes of an Intel-based Mac with an Apple T2 Security ...
An Intel-based Mac with an Apple T2 Security Chip has a variety of boot modes that can be entered at boot time by...
Read more >
Best way to detect Mac OS X or Windows computers with ...
I tested on my Mac if I change the userAgent to iPhone or Chrome Windows, navigator.platform remains MacIntel. navigator.platform is not spoofed ...
Read more >
Identifying Your Operating System (OS) - Lumen Learning
Another good way to see whether you are running Windows or Mac is simply to turn the computer on. As the operating system...
Read more >
platform — Access to underlying platform's identifying data ...
On macOS (and perhaps other platforms), executable files may be universal files ... Returns a single string identifying the underlying platform with as...
Read more >
How to open a Mac app from an unidentified developer
You'll still be prevented from opening anything macOS doesn't recognise, but at least you will be able to open apps that weren't purchased ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found