Python 3 – Create Module to upload on PyPi

First of all create your module. For example schachtler_bw:

 
def print_lvl(liste, einzug=False, ebene=0):
    """Diese Funktion erwartet ein positionelles Argument namens "liste",
    das eine beliebige Python-Liste (mit eventuellen eingebetten Listen) ist.
    Jedes Element der Liste wird (rekursiv) auf dem Bildschirm auf einer eigenen Zeile ausgegeben.
    Mit dem dritten Argument (True, False) wird angegeben ob sie einen Einzug wuenschen.
    Mit dem dritten Argument "ebene" koennen bei eingebetten Listen Tabulatoren eingesetzt werden."""
    
    # Ich bin ein Testkommentar
    for element in liste:
        if isinstance(element, list):
            print_lvl(element, einzug, ebene+1)
        else:
            if (einzug == True):
                for tab in range(ebene):
                    print('\t',end='')
            print(element)

After that create your setup.py file:

from distutils.core import setup

setup(
	name = "schachtler_bw",
	version = "1.3.1",
	py_modules = ["schachtler_bw"],
	author = "Benedikt Winder",
	author_email = "benedikt.winder@gmail.com",
	url = "http://www.bewi.at",
	description = "A simple printer of nested lists",
	)

After that you can register your current Python version to the PyPi Website. Change your path to your two files you have created before.

 
python3 setup.py register

After that you can upload your module.

python3 setup.py sdist upload

Register your Module in your current environment:

python3 setup.py install
Print Friendly, PDF & Email

Create Howto

Create empyt git repository. First you need to create a folder!

git init

Clone the repository

git clone benutzername@host:/pfad/zum/repository

Add files (Now it’s in the Index)

git add README.txt

oder

git add *

Commit your changes (Now it’s in the HEAD)

git commit -m "Ich habe eine Readme erstellt"

Copy to server:
If the repo is empty:

git remote add origin git@github.com:benedikt-winder/github_test.git

and then:

git push origin master

This will copy your changes to the master branch

Create new branch

git checkout -b feature_x

Add your files and copy to server

git push origin feature_x

To go back to the master branch

git checkout master

To update the specified branch

git pull origin master

To merge for example from master branch to feature_x branch

git merge master

Dont forget to push afterwards.

Print Friendly, PDF & Email

Git

Clone Git Repo

git clone git@github.com:fhvis/eval2012.git

Create Branch

git checkout -b 'mein_branch'

Change your files in your current folder where the new files are, add the files and commit it.

git add file.py
git commit -am 'Added first files'

Next create the Branch and with following script

git commit -am 'Added first set of git commandline examples'

If the remote branch doesn’t exists create it with this script.

git-publish-branch

Before we push we merge before the master branch

git merge origin/master

If remote branch already exist push to the server

git push

Change branch

git checkout dobe-manifest
Print Friendly, PDF & Email

Kubuntu 12.10 on Lenovo X230

With a clean install you will get problems if you have a external Monitor connected. You will get only a blank screen when you start to Kubuntu. A simple workaround is to change some boot parameters. If you change this i also enabled the power saving things vor Intel’s Sandy Bridge Controllers.

sudo vim /etc/default/grub

Change following that it looks like this:

GRUB_CMDLINE_LINUX_DEFAULT="i915.i915_enable_rc6=1 i915.i915_enable_fbc=1 pcie_aspm=force"
sudo update-grub
Print Friendly, PDF & Email

Android SDK (K)Ubuntu 64-bit

Compability

If you download the Android SDK for Linux and you have a 64-bit PC you will be notice that you can’t run all tools. You must first install all 32-bit libaries. Google provide the SDK only in 32-bit.

apt-get install ia32-libs

After that all should running perfectly.

Path

Add these line to your .bashrc file at the end

export PATH=/opt/android-sdk-linux/platform-tools:$PATH
Print Friendly, PDF & Email

SSH Key Authentication

Install packages on the server

pacman -S openssh

On the Client

ssh-keygen -t rsa
ssh-copy-id -i .ssh/id_rsa.pub user@yourserver

Disable Password Login on the server

Edit follwing lines in this file: /etc/ssh/sshd_config

UsePAM no
PasswordAuthentication no

Restart service: rc.d restart sshd

/etc/ssh/sshd_config

Changes are bold

# $OpenBSD: sshd_config,v 1.84 2011/05/23 03:30:07 djm Exp $

# This is the sshd server system-wide configuration file. See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented. Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

# The default requires explicit activation of protocol 1
Protocol 2
AllowUsers root bw

# HostKey for protocol version 1
#HostKey /etc/ssh/ssh_host_key
# HostKeys for protocol version 2
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_dsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key

# Lifetime and size of ephemeral version 1 server key
#KeyRegenerationInterval 1h
#ServerKeyBits 1024

# Logging
# obsoletes QuietMode and FascistLogging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

LoginGraceTime 1m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#RSAAuthentication yes
#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile .ssh/authorized_keys

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#RhostsRSAAuthentication no
# similar for protocol version 2
#HostbasedAuthentication no
# Change to yes if you don’t trust ~/.ssh/known_hosts for
# RhostsRSAAuthentication and HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don’t read the user’s ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!

##########################################
###### PASSWORD AUTHENTICATION ###########
##########################################
UsePAM no
PasswordAuthentication no

#PermitEmptyPasswords no

# Change to no to disable s/key passwords
ChallengeResponseAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

# Set this to ‘yes’ to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of “PermitRootLogin without-password”.
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to ‘no’.

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#UsePrivilegeSeparation yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS yes
#PidFile /var/run/sshd.pid
MaxStartups 3:30:10
#PermitTunnel no
#ChrootDirectory none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem sftp /usr/lib/ssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
# X11Forwarding no
# AllowTcpForwarding no
# ForceCommand cvs server

Windows Integration Explorer

http://www.swish-sftp.org/

Print Friendly, PDF & Email

PPTPD Server Archlinux

PPTP Server

Install package:

pacman -S pptpd

Edit this file: /etc/pptpd.conf

option /etc/ppp/pptpd-options
# IP who has the server
localip 192.168.0.25
remoteip 192.168.0.200-210

Edit this file: /etc/ppp/pptpd-options

name pptpd
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
ms-dns 8.8.8.8
ms-dns 8.8.4.4

Edit this file: /etc/ppp/chap-secrets

<username>     pptpd     <password>   *

Edit this file: /etc/sysctl.conf

Uncomment follwoing line

net.ipv4.ip_forward=1

Apply settings:

sysctl -p

Firewall

You must install a firewall. It’s for your saftey. 😉

Install ufw:

pacman -S ufw

Edit following line in the file: /etc/default/ufw

DEFAULT_FORWARD_POLICY=”ACCEPT”

Now change /etc/ufw/before.rules, add following code after header and before *filter line

# nat Table rules
*nat
:POSTROUTING ACCEPT [0:0]
# Allow traffic from clients to eth0
-A POSTROUTING -s 192.168.0.0/24 -o eth0 -j MASQUERADE
# don.t delete the .COMMIT. line or these nat table rules won.t be processed
COMMIT

Open Ports:

ufw allow 1723

Restart Firewall

ufw disable
ufw enable

PPTP is on Port: 1723

Now start the server:

rc.d start pptpd
Print Friendly, PDF & Email