Repository: saltstack/salt
Pull request: Fix #62281


### What does this PR do?
added if-else block to check the python version and fill repo_path with correct data regarding the python major version

### What issues does this PR fix or reference?
Fixes: #62281 

Problem statement:
[BUG] module 'os' has no attribute 'getcwdu'
**Description**
Salt Package Manager (SPM) is using a deprecated Python method called `os.getcwdu()`, which used to exist in Python 2.x, but not anymore on Python 3.x. This causes the following exception when calling `spm create_repo .` on SPM version 3004:

```
[ERROR   ] An un-handled exception was caught by salt's global exception handler:
AttributeError: module 'os' has no attribute 'getcwdu'
Traceback (most recent call last):
  File "/usr/bin/spm", line 11, in <module>
    salt_spm()
  File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 533, in salt_spm
    spm.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/spm.py", line 38, in run
    client.run(self.args)
  File "/usr/lib/python3.6/site-packages/salt/spm/__init__.py", line 129, in run
    self._create_repo(args)
  File "/usr/lib/python3.6/site-packages/salt/spm/__init__.py", line 750, in _create_repo
    repo_path = os.getcwdu()
AttributeError: module 'os' has no attribute 'getcwdu'
Traceback (most recent call last):
  File "/usr/bin/spm", line 11, in <module>
    salt_spm()
  File "/usr/lib/python3.6/site-packages/salt/scripts.py", line 533, in salt_spm
    spm.run()
  File "/usr/lib/python3.6/site-packages/salt/cli/spm.py", line 38, in run
    client.run(self.args)
  File "/usr/lib/python3.6/site-packages/salt/spm/__init__.py", line 129, in run
    self._create_repo(args)
  File "/usr/lib/python3.6/site-packages/salt/spm/__init__.py", line 750, in _create_repo
    repo_path = os.getcwdu()
AttributeError: module 'os' has no attribute 'getcwdu'
```

**Setup**

Docker container. Image is build with the following Dockerfile:

```
FROM opensuse/leap

RUN zypper refresh && zypper install -y salt-master

ENTRYPOINT ["sleep","infinity"]
```
  
**Steps to Reproduce the behavior**
1. Install salt-master
2. Run `spm create_repo .` on any directory

**Expected behavior**
The repository is correctly initialized on the current working directory.

**Versions Report**
<details><summary>salt --versions-report</summary>
(Provided by running salt --versions-report. Please also mention any differences in master/minion versions.) 

```yaml
Salt Version:
          Salt: 3004
 
Dependency Versions:
          cffi: 1.13.2
      cherrypy: Not Installed
      dateutil: Not Installed
     docker-py: Not Installed
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 2.10.1
       libgit2: Not Installed
      M2Crypto: 0.38.0
          Mako: Not Installed
       msgpack: 0.5.6
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     pycparser: 2.17
      pycrypto: Not Installed
  pycryptodome: Not Installed
        pygit2: Not Installed
        Python: 3.6.15 (default, Sep 23 2021, 15:41:43) [GCC]
  python-gnupg: Not Installed
        PyYAML: 5.4.1
         PyZMQ: 17.1.2
         smmap: Not Installed
       timelib: Not Installed
       Tornado: 4.5.3
           ZMQ: 4.2.3
 
System Versions:
          dist: opensuse-leap 15.4 
        locale: UTF-8
       machine: x86_64
       release: 5.13.0-51-generic
        system: Linux
       version: openSUSE Leap 15.4 
```
</details>

Hints from issue discussion:
Hi there! Welcome to the Salt Community! Thank you for making your first contribution. We have a lengthy process for issues and PRs. Someone from the Core Team will follow up as soon as possible. In the meantime, here’s some information that may help as you continue your Salt journey.
Please be sure to review our [Code of Conduct](https://github.com/saltstack/salt/blob/master/CODE_OF_CONDUCT.md). Also, check out some of our community resources including:

  - [Community Wiki](https://github.com/saltstack/community/wiki)
  - [Salt’s Contributor Guide](https://docs.saltproject.io/en/master/topics/development/contributing.html)
  - [Join our Community Slack](https://join.slack.com/t/saltstackcommunity/shared_invite/zt-3av8jjyf-oBQ2M0vhXOhJpNpRkPWBvg)
  - [IRC on LiberaChat](https://web.libera.chat/#salt)
  - [Salt Project YouTube channel](https://www.youtube.com/channel/UCpveTIucFx9ljGelW63-BWg)
  - [Salt Project Twitch channel](https://www.twitch.tv/saltprojectoss)

There are lots of ways to get involved in our community. Every month, there are around a dozen opportunities to meet with other contributors and the Salt Core team and collaborate in real time. The best way to keep track is by subscribing to the Salt Community Events Calendar.
If you have additional questions, email us at saltproject@vmware.com. We’re glad you’ve joined our community and look forward to doing awesome things with you!

Commit message: Merge branch 'master' into master

Patch to review:
diff --git a/salt/spm/__init__.py b/salt/spm/__init__.py
index d945baee2718..bc939b3c1885 100644
--- a/salt/spm/__init__.py
+++ b/salt/spm/__init__.py
@@ -747,7 +747,9 @@ def _create_repo(self, args):
             raise SPMInvocationError("A path to a directory must be specified")
 
         if args[1] == ".":
-            repo_path = os.getcwdu()
+            repo_path = os.getcwd()
+            if sys.version_info.major == 2:
+                repo_path = os.getcwdu()
         else:
             repo_path = args[1]
 


Code review comments:
diff_hunk: @@ -747,7 +747,9 @@ def _create_repo(self, args):
             raise SPMInvocationError("A path to a directory must be specified")
 
         if args[1] == ".":
-            repo_path = os.getcwdu()
+            repo_path = os.getcwd()
+            if sys.version_info.major == 2:
path: salt/spm/__init__.py
text: @user1:
we no longer support python version 2 so shouldn't need the if-else block. just the change to getcwd should be enough.