Monday, October 29, 2018

Basic git commands

So you are starting to research about code versioning and heard about git and github?

Below are some very few basic commands that I use to clone a github repository, create a new branch to develop a new feature or fix a bug, add and commit modifications to the branch and push it to github's repository.


# To clone a repository is the same as to download the files from a github repository to your local machine:
git clone <github-repository-address>


# Then you will create a new branch
git checkout -b <new-branch>


# after your development is ready, you add it to git and commit
git add .
git commit -m "<commit message>"


# after the commit is done, change to master and merge it
git checkout master
git merge <new-branch>


# after the merge is done, push it to the remote repository
git push origin master

WARNING: lib not found when converting python script using pyInstaller

When trying to convert a Python script to .exe using pyInstaller, warning message is shown:
WARNING: lib not found: api-ms-win-crt-math-l1-1-0.dll dependency of C:\Program Files (x86)\Python\python.exe


The command line used is:
pyinstaller --onefile --noconsole main.py


Looking for the file, I could find it in the following path:
C:\Program Files (x86)\Java\jre1.8.0_181\bin


pyinstaller version in use is 3.3.1 and the latest one available at the moment is 3.4, so I proceeded on upgrading it.


Firstly uninstalling the current pyinstaller version:
pip uninstall pyinstaller


Then installing the newest and desired version:
pip install pyinstaller


After updating pyInstaller version, build was successfull:
set JAVA_HOME=C:\Program Files (x86)\Java\jre1.8.0_181
set PATH=%JAVA_HOME%\bin:%PATH%
pyinstaller --onefile --noconsole main.py

Wednesday, February 7, 2018

Unable to connect to the database error when running IRM on IP17

Sometimes when running the IRM as part of the upgrade for Siebel IP17 version, you may face "Unable to connect to the database" error.

To address it, include the following section on tools.cfg file:
[InfraDatabase]
SQLTraceThreshold = -1

Wednesday, January 3, 2018

DJANGO - Not able to run collectstatic on a shared hosting server using cPanel

As part of setting-up a new Django application, one will need to run collectstatic in order to copy all static files.

It happens that, as I have a shared account on a hosting comp, I have no access to the prompt, the only option to execute this kind of commands was through Execute Command on cPanel:



And, when trying to run collectstatic, this is the output I was facing:

python manage.py collectstatic

You have requested to collect static files at the destination location as specified in your settings.
This will overwrite existing files!
Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: Traceback (most recent call last):
File "manage.py", line 15, in <module>execute_from_command_line(sys.argv)
File "/home/user/virtualenv/mysite/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/user/virtualenv/mysite/3.5/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/user/virtualenv/mysite/3.5/lib/python3.5/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/user/virtualenv/mysite/3.5/lib/python3.5/site-packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/home/user/virtualenv/mysite/3.5/lib/python3.5/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 186, in handle
if input(''.join(message)) != 'yes':
EOFError: EOF when reading a line



What I figured out is that collectstatic command was waiting for an input and I wasn't able to provide any as Execute Command from cPanel doesn't allow me to interact after you submit any command.

To overcome such limitation, I had to append the --noinput argument, so the command was successfully executed.

Another alternative, if your hosting company provides a remote MySQL access, you may be able to open a cmd prompt from your computer, connecting to the server database, so you'll be able to interact with the script as much as you need. This is what I started doing after discovered this alternative, it's easier and there are some commands that don't allow us to have a --noinput argument.

Hope this helps everyone who may face a similar problem.