The shutil module helps you to accomplish tasks, such as: copying, moving, or removing directory trees.
This python script creates a zip file in the current directory containing all contents of dir and then clears dir.
import shutil
from os import makedirs
def zip(out_fileName, dir):
shutil.make_archive(str(out_fileName), 'zip', dir)
shutil.rmtree(dir)
makedirs(dir[:-1])
Is a blog about python programming language. You can see my work with python programming language, tutorials and news.
Sunday, October 21, 2018
The shutil python module.
Posted by
Cătălin George Feștilă
Labels:
2.7,
2017,
python,
python modules,
shutil,
tutorial,
tutorials
The scapy python module - part 002.
This is another python tutorial about scapy python module.
The last was made on Linux and now I used Windows 10 OS.
Let's install this python module with python version 2.7.13 and pip.
The last was made on Linux and now I used Windows 10 OS.
Let's install this python module with python version 2.7.13 and pip.
C:\>cd Python27
C:\Python27>cd Scripts
C:\Python27\Scripts>pip install scapy
Collecting scapy
Downloading scapy-2.3.3.tgz (1.4MB)
100% |################################| 1.4MB 736kB/s
In the tar file c:\users\mythcat\appdata\local\temp\pip-26vi9x-unpack\scapy-2.3.3.tgz
the member scapy-2.3.3/README is invalid: unable to resolve link inside archive
Installing collected packages: scapy
Running setup.py install for scapy ... done
Successfully installed scapy-2.3.3
The next step is to deal withC:\Python27\Scripts>python
Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:42:59) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import scapy
>>> from scapy import *
>>> dir(scapy)
['VERSION', '_SCAPY_PKG_DIR', '__builtins__', '__doc__', '__file__', '__name__', '__package__',
'__path__', '_version', '_version_from_git_describe', 'base_classes', 'config', 'dadict', 'data',
'error', 'os', 'plist', 'pton_ntop', 're', 'subprocess', 'supersocket', 'themes', 'utils',
'with_statement']
This is not working on WINDOWS
Posted by
Cătălin George Feștilă
Labels:
2.7,
2017,
python,
python modules,
scapy,
tutorial,
tutorials
Using PyUSB with python 3.x .
C:\Python34\Scripts>pip3.4.exe install PyUSB
Downloading/unpacking PyUSB
Running setup.py (path:C:\Users\mythcat\AppData\Local\Temp\pip_build_mythcat\PyUSB\setup.py)
egg_info for package PyUSB
Installing collected packages: PyUSB
Running setup.py install for PyUSB
Successfully installed PyUSB
Cleaning up...
Now you need to install this filter from here.If not, you can get errors like this: raise NoBackendError('No backend available')
usb.core.NoBackendError: No backend available
Let's make a simple test example:
import usb.core
import usb.util
import sys
class find_class(object):
def __init__(self, class_):
self._class = class_
def __call__(self, device):
# first, let's check the device
if device.bDeviceClass == self._class:
return True
# ok, transverse all devices to find an
# interface that matches our class
for cfg in device:
# find_descriptor: what's it?
intf = usb.util.find_descriptor(
cfg,
bInterfaceClass=self._class
)
if intf is not None:
return True
return False
all = usb.core.find(find_all=1, custom_match=find_class(7))
print (all)
And show the result:C:\Python34>python.exe usb_devs.py
< generator 0x0000000003d8d5e8="" at="" device_iter="" object="" >
Posted by
Cătălin George Feștilă
Labels:
2017,
error,
python 3,
python modules,
PyUSB,
tutorial,
tutorials
The ansible python module - part 001.
Ansible is an IT automation tool.
It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.
First, you need to install the VCForPython27.
Install now the pycrypto python module:
It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates.
First, you need to install the VCForPython27.
Install now the pycrypto python module:
C:\Python27\Scripts>pip install --upgrade --trusted-host pypi.python.org pycrypto
Collecting pycrypto
Downloading pycrypto-2.6.1.tar.gz (446kB)
100% |################################| 450kB 3.8MB/s
Installing collected packages: pycrypto
Running setup.py install for pycrypto ... done
Successfully installed pycrypto-2.6.1
C:\Python27\Scripts>pip install --trusted-host pypi.python.org ansible
Collecting ansible
Downloading ansible-2.3.0.0.tar.gz (4.3MB)
100% |################################| 4.3MB 365kB/s
Requirement already satisfied: jinja2 in c:\python27\lib\site-packages (from ansible)
Collecting PyYAML (from ansible)
...
Installing collected packages: ansible
Running setup.py install for ansible ... done
Successfully installed ansible-2.3.0.0
Posted by
Cătălin George Feștilă
Labels:
2.7,
2017,
ansible,
pip2.7,
pycrypto,
python,
python modules,
tutorial,
tutorials
Programmer's Notepad - free editor with PyPN python module.
Programmer's Notepad is a free, open source, text editor with special features for coders.
This editor comes with a variety of text clips representing common programming languages.
I saw 43 of text clips to start your programming.
Featuring
Syntax highlighting
Text Clips for simple text insertion
Code folding / outlining
Flexible Regular Expression support
Code navigation using Ctags
Projects for navigating large code bases
Extend using Python or C++
For example, if you start with the HTML then every tag will autocomplete with the end tag.
You can install the PyPN python module and used with this editor:
You can donate to support the project.
This editor comes with a variety of text clips representing common programming languages.
I saw 43 of text clips to start your programming.
Featuring
Syntax highlighting
Text Clips for simple text insertion
Code folding / outlining
Flexible Regular Expression support
Code navigation using Ctags
Projects for navigating large code bases
Extend using Python or C++
For example, if you start with the HTML then every tag will autocomplete with the end tag.
You can install the PyPN python module and used with this editor:
C:\Python364\Scripts>pip install PyPN
Collecting PyPN
...
Installing collected packages: PyPN
Successfully installed PyPN-0.9
More about PyPN module can be found here.You can donate to support the project.
Posted by
Cătălin George Feștilă
Labels:
2018,
PyPN,
python,
python 3,
python modules,
tutorial,
tutorials
Subscribe to:
Posts (Atom)