Jun 22, 2017

Visual Studio Code using for Python development

Some time ago, I wrote some programs in python. Now I had to search for some problems in the
During the old day's, I used the Python-Plugins for the NetBeans IDE.

Since I got a new laptop and had to change from Linux to Windows, I do not have the "old"
environment anymore.

Now I had installed Visual Studio Code and tried to open the python source code.

I played around some time ago and installed a bunch of extensions and also some for python:

Here you see the selected button to get to the extensions and the one's I could find for python.

In the code itself, I still miss a "navigator" or "function list", but it's possible to navigate through the
source code. Select a method call and hover with the <Ctrl>-Key pressed:

This seems worth to investigate more on Visual Studio Code.

Jun 20, 2017

Using sshd in a docker container by the help of supervisord

On my windows box, I'm running docker-toolbox.

In one container started by docker-compose with a database container, I need ssh access, to use
e.g. WinSCP to copy files for testing inside the container.

In the Dockerfile, I used CentOS as the base image and installed open-ssh-server

RUN yum -y update
RUN yum -y install rpm ksh openssh-server supervisor compat-libstdc++-33 compat-libstdc++-296 libstdc++ glibc.i686 libgcc.i686 tar python-setuptools mariadb unzip dos2unix
RUN easy_install supervisor
#configure supervisor as process starter
ADD ./supervisor.conf/  /etc/supervisord.d/
COPY id_rsa.pub /root/.ssh/authorized_keys
RUN chmod go-rwx /root.ssh; chmod go-rwx /root/.ssh/authorized_keys
RUN cd /etc/ssh; ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key

Before I added the ssh-keygen to the container, I tried to access the ssh-Daemon, but I got the 
error in debug-Mode of sshd:
No supported key exchange algorithms
After adding the ssh-keygen, I can login with e.g WinSCP. 

Here's the ssh.ini to add to the supervisord-config: 

command=/usr/sbin/sshd -D

May 8, 2017

Virtualbox doesn't mount local shared folder, if there is a windows mapped drive before the locale one.

The docker-toolbox uses VirtualBox  to boot a small Linux (boot2docker.iso) to provide the
docker engine.

To use local directories inside the containers, the linux-system in VirtualBox must mount the Windows directories.

There is an option named '--virtualbox-share-folder' to be used with the docker-machine.exec create
or you can map the Shared-Folders in the VirtualBox GUI:

The 'Name' part is the mount-Point in the linux-system.

For the containers you can use the "-v" volume option to mount the directories into the container.

For me, the L: drive was not available when I started the virtual machine with

docker-machine.exe start <virtualLinuxSystem> 

and as a result of this, also the local directory after the mapped networkdrive was not available in the
virtual machine and in the container.

After changing to the mapped networkdrive within the Windows Explorer, the mounts are available in the virtual linux system:

Apr 26, 2017

Convert a SubVersion Repository to GIT

Git has an extension command git-svn which allows to directly interact with a SubVersion repository.

To do the conversion to git completely, I started a container with Fedora as the base image:

docker run -it --name fed --hostname=fed fedora bash

Install git and the subversion extension in the container

dnf install git-svn.x86_64 git.x86_64

Clone the subversion repo:

mkdir <repodir>
cd <repodir>
git svn init --stdlayout --username=<svnuser> --include-paths=<path2include> http://svn.server.h
git svn fetch --all

To get the branches, checkout them locally:

for remote in `git branch -r |grep -v tags | sed -e 's#origin/##'`; do
  git checkout --track -b $remote

Now create the tags, which are branches from the import from SVN:
for remote in `git branch -r |grep tags`; do
  ref=`git show-ref $remote |awk '{print $1}'`;
  tag=`echo $remote |awk -F / '{print $(NF)}'`;
  git tag $tag $ref;

Add the new GIT repo as a remote and push the branches and the tags:

git remote add <name> http://git.server.home/scm/git/<targetRepoInGit>
git push --all <name>
git push --tags <name> 

Now the Repo is on the GIT-Server http://git.server.home/.

Apr 25, 2017

Converting Mercurial (hg) repositories to GIT

Git has an extension command remote-hg which allows to directly interact with an HG (mercurial) repository.

To keep the repository as a mercurial repo you can directly checkout with git and work as if the
repo would be a git repo:

git clone hg::http//hg.server.home/repo

To do the conversion to git completely, I started a container with Fedora as the base image:

docker run -it --name fed --hostname=fed fedora bash

Install git and the remote-hg extension in the container

dnf install git-remote-hg.noarch git.x86_64

Clone the mercurial repo:

git clone hg::http://hg.server.home/repo

To get the branches, checkout them locally:

for remote in `git branch -r |grep branches | sed -e 's#origin/##'`; do
git checkout --track -b $remote

Now rename the branches  if you like

for b in `git branch -l | grep branches | sed -e 's#branches/##'`; do
git branch -m branches/$b $b;

Add the new GIT repo as a remote and push the branches and the tags:

git remote add <name> http://git.server.home/scm/git/<targetRepoInGit>
git push --all <name>
git push --tags <name> 

Now the Repo is on the GIT-Server http://git.server.home/.

Conversion of a CVS repository to GIT

After detecting an old CVS (Concurrent Version System) , we'd like to convert this repository with
multiple modules to a GIT repository.

There is a module in git named git-cvsimport to import a CVS Repository.
The basic command is:
git cvsimport -o <targetbranch> -d <CVSROOT like :pserver:<host>:/repo <cvs-module>   
The problem is, that this command converts one CVS-Module (see CVS/module file) of the

On the repository I'm working on, there are multiple modules and they belong together. After
a little search, I found a script handling multiple modules:
see: http://max.romantschuk.fi/blog/2009/dec/29/importing-cvs-modules-single-git-repo/

The script linked in this page named git-cvsmod2subdir.sh is doing the job for me.
Bring in the script to the docker container.

Startup an interactive  docker container with e.g. CentOS as the image

docker run -it --name centos centos bash
yum -y install git git-cvs cvs cvsps 

git config --global user.email "email@domain"
git config --global user.name "Your Name"
 git init <gitrepo>  cd <gitrepo>

Before using the script, a local git repository has to be initialized as shown above, after this,
the CVSROOT has to be modified in git-cvsmod2subdir.sh and convert all repos with the
following command.

../git-cvsmod2subdir.sh <module1> <module2> <module3>

This sequence converts each module and merges it into the new GIT-Repository with a merge commit.

Mar 28, 2017

Modifying the content of multiple files in different directories with Powershell

I had the problem to have multiple git repositories checked out from one server.
But now the GIT-Server has moved to a different address and the config file in each
git repository points to the wrong server.

The quick solution would have been, to add the old server into the hosts files with the
IP-Address of the new one.

But the "clean" solution is to update the config file in each repository. On a Linux Box,
a find and sed would have done the job for me.

But I'm now on a Windows Box. I could install the cygwin package or something similar to get
the UNIX-Tools, but I have already Powershell 

To get the files, the simple command is:

Get-ChildItem */.git/config 

To modify the content: 

Get-ChildItem */.git/config | foreach { (Get-Content $_).replace('scm.home.com:8080', 'new-scm.home.com:8082') | Set-Content $_ }

The foreach ( ForEach-Object) loop is taken, to have the Object of each config-File available to
store it again with the "Set-Content $_". 

Mar 6, 2017

BLU Life One X2 was not detected as MTP device on Windows 8.1

After connection the Phone BLU Life One X2 on my laptop, Windows 8.1 PRO didn't recognize the device. The DeviceManager showed an error in the INF-Section. After searching for a resolution,
I was installing some other drivers and many other things, but without success.

Today I found a short hint here.

(1) Go to C:\Windows\INF
(2) Type "wpdmtp.inf" in search bar provided to the right of the address bar in Windows 10.
(3) Once you found it, just right click on it and select install. It will take a very few seconds.
(4) Connect your device to the pc.

After following this simple steps, the Phone was recognized by the system and the internal and SD Card storage is accessible.