Python

3K

Solutions

23

Articles & Videos

2K

Contributors

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.

Share tech news, updates, or what's on your mind.

Sign up to Post

hi All,

kindly help me to write a shell or python script to delete the weblogic files. The files are rotated but need to be deleted which are 30 days old. the find command doesn't delete the files because the number of files are huge.

below is the  .logs format of the weblogic servers
/wls1034/Middleware/user_projects/domains/Domain/servers/server3/logs/

server3.log00585
 server3.log00586
 server3.log00587
server3.log00588
server3.log00589
server3.log00590
server3.log00603
server3.log00604

server3.out00035
server3.out00034
server3.out00036
server3.out00037
0
On Demand Webinar: Networking for the Cloud Era
LVL 8
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Hi all,

Need to write a python or shell script for email alert on memory utilisation of the server.
we are glance tool to monitor the cpu and memory utilisation for our weblogic servers. If the memory utilisation reached 80% it should alert us through mail so that we can check and restart if required.

below is the output of glance file
B0000A Glance C.04.70.000       04:56:38    x86_64                                                                     Current  Avg  High
------------------------------------------------------------------------------------------------------------------------------------------------------
CPU  Util   SU                                                                                                                       |  1%    3%   27%
Disk Util                                                                                                                            |  0%    0%    7%
Mem  Util   U                      UB     B                                                                                          | 26%   26%   26%
Swap Util                                                                                                                            |  0%    0%    0%
------------------------------------------------------------------------------------------------------------------------------------------------------
                                                                     PROCESS LIST                     …
0
I am new to python, Now am trying to update a cell with hyperlink which refer to another cell sheet. i have tryed with below code but while click the cell its showing error with "Cannot open the specified file". Could you any one can help on this ?

from win32com.client import Dispatch
excel = Dispatch('Excel.Application')
book = excel.Workbooks.Open("Location.xls")
sheet = book.Worksheets(1)
cell_location = sheet.Cells(2,2)
cell_destination = book.Worksheets(2).Cells(1,3)
sheet.Hyperlinks.Add(Anchor=cell_location, Address=cell_destination)
book.Save()
0
like how can i create 2X2 or 4X4 or 3X4 matrices, instead of create while writing the program, i just want to read my own values from keyboard using python code.
0
I have need of a context menu in Windows 7 Explorer that is essentially the "move to folder" command, but with a twist.

Instead of bringing up a dialog of where to move a file, I'd like to bring up a list.  The list would have three types of entries:
1) Recently visited folders
2) List of favorite folders (pinned)
3) Standard browse to folder

So, I have a few questions:

  1. Has this been done already?  If so, where can I get it?
  2. Where can I get Windows' recently visited folders programmatically?  If necessary, I can get these from recently used files, so where would I get the recently used files list programmatically?
  3. Is there any source code I can build off of which does something similar (preferably Python)?  If necessary: C++, C#,  Java?

Thanks!

I'm aware of the CodePlex source code for the MS examples, but they are long and pretty different from what I'm trying to acheive.
http://1code.codeplex.com/SourceControl/changeset/view/57974#Visual Studio 2010/VBShellExtContextMenuHandler/FileContextMenuExt.vb
0
Hi Experts,

 I am looking  for a data science project(using python) with complete source code and documentation , please help me with the same and will appreciate your help in this regard.  

Thanks,
SRK,
0
I currently login to the time from website using the following script.


browser = webdriver.Chrome('E:/Shared Folders/Users/runnerjp/chromedriver/chromedriver.exe')
browser.get("https://www.timeform.com/horse-racing/account/sign-in?returnUrl=%2Fhorse-racing%2F") 
time.sleep(3)
username = browser.find_element_by_id("EmailAddress")
password = browser.find_element_by_id("Password")
username.send_keys("usr")
password.send_keys("pass")
login_attempt = browser.find_element_by_xpath("//input[@type='submit']")
time.sleep(3)
login_attempt.submit()

Open in new window


it works but I find using Chrome web driver is hammering my CPU. Is there an alternative code I could use that does not mean I need to physically load the page to sign in?
0
Please review below code, not able to copy config from device to tftp and vice versa
import paramiko
ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect('192.168.1.12', port=22, username='cisco', password='cisco')

stdin, stdout, stderr = ssh.exec_command('copy tftp: flash: ')

stdin.write('192.168.1.10')

stdin.write('\n')

stdin.flush()

stdin.write('demotesting')
stdin.write('\n')
stdin.flush()

stdin.write('dest_demo')
stdin.write('\n')

output = stdout.readlines()
print '\n'.join(output)
ssh.close()

Open in new window


error :

L
ine has invalid autocommand "copy tftp: flash: "

Open in new window

0
I want to invoke a python script from my C++ app and get the data from the python script into my C++ app. How do I do this?

example: testing.py   reads data from and ADC -

C++ app - invoke testing.py  ; data = python testing.py
0
Im using python and paramiko. Im trying to backup a network device router using python. Below is my script. However im getting error

import paramiko
import sys
import time

HOST = "10.11.214.143"
USER = "admin"
PASS = "passwd"


client1=paramiko.SSHClient()
client1.set_missing_host_key_policy(paramiko.AutoAddPolicy())

client1.connect(HOST,username=USER,password=PASS)
  print "SSH connection to %s established" %HOST

#copying config to tftp
stdin, stdout, stderr = client1.exec_command('copy nvram:startup-config tftp: 10.11.214.144')
print stdout.read()


Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    client1.exec_command('copy nvram:startup-config tftp:')
  File "C:\Python27\lib\site-packages\paramiko\client.py", line 436, in exec_command
    chan = self._transport.open_session(timeout=timeout)
  File "C:\Python27\lib\site-packages\paramiko\transport.py", line 716, in open_session
    timeout=timeout)
  File "C:\Python27\lib\site-packages\paramiko\transport.py", line 800, in open_channel
    raise SSHException('SSH session not active')
SSHException: SSH session not active

Open in new window

0
[Webinar] Learn How Hackers Steal Your Credentials
LVL 8
[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

It seems I need to write an Inkscape extension to fill in names from a csv file and write the name on gravesites in cemetery lots.  There are about 100 lots with 12 gravesites per lot.  I could draw all of the names by hand but it seems like more fun to learn perl, python, and extensions.   Does anybody have any hints?
0
I am trying to write a python script to send an email. I get the Import Error SMPTLib not found.
0
Need a python script that will take backup of cisco ios switch to tftp server
0
Hello, Experts,

I have an issue with a script where I want the end-user once the app is hit to see the main menu. I have four definitions doing separate tasks (updating, querying or adding in records in a database).

I want my main screen to pop up a list of items for the end users to select. I read that a def main() function is the route to go. Tested it out and I have no luck running it.

def main():
    user_exit =  5
    while True:
            #prints statements that lead the end-user to decide what they would like to do
        print('Welcome to the ROWriter Database applet! What would you like to do?')
        print('')
        print('1) Insert a new store CIM info...')
        print('2) Update an existing store CIM info...')
        print('3) Delete an exisiting store CIM info...')
        print('4) Search for CIM')
        print('5) Exit the application...')
    
            #accepts user input and converts it to a string and stores into a variable
        user_input = int(input('Enter option:'))
        #if user input is equal to the exit variable then the application exits
        if user_input == user_exit:
            break
        elif user_input == 1:
                option_one()
        elif user_input == 2:
                option_two()
        elif user_input == 4:
                option_four()
  
if__name__ == "__main__":
    
    main()  

Open in new window

0
When I execute Python script I get error message:
 NameError: name 'sys' is not defined.

I tried putting the following:
import sys
prior to the statement in question.

However, I get other more complicated errors such as the following:

Traceback (most recent call last):
line 263, in <module>
connect(user, password, url=url)
NameError: name 'connect' is not defined

This code was written by someone else and I am trying to run it to make STIG changes in Weblogic.
0
Hi
i need suggestions some material for beginners to learn python...any books video lectures etc.  will be helpful...
I am asking this for my friend who is beginning to learn it and has no prior knowledge of programming..he is from a different field.

thanks
0
How to automate a cisco ios upgrade process using a script like python or any other script or any other tool
0
Am  working on Mcafee  WEB API  projct  with Python.  i have this erorr Failed to reach the server 200.200.200.50:8443. Error/reason: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:661)>.

Do want to know  how to resolve it.

Thanks
0
Hello,
I hate to ask; could go searching the internet for an answer, yet this could be some easy points for you.
I have installed PyDev in Eclipse.  When the Python console is used the font color is a fluorescent green.
I looked in the Eclipse/Window/Preference/EditBox section and elsewhere to change the color and can't find it.
Do you know where or how to change it.
0
Free Tool: IP Lookup
LVL 8
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Sir, i am using SET of Social Engineer toolkit on kali linux and on doing site cloning it gives me the error of Python OpenSSL was not detected or PEM file no found...
0
Hello, I searched the internet, yet could not find any information on the possibility of installing docStrings into Eclipse.
Might you know if it is possible to have this feature with PyDev?
0
Hi Team,

I am having a Python script which insert data into PostgreSQL from XML file. However, we have updated the python version to 3.6.1 it does not add any data into PostgreSQL database and does not throw any error message on command line screen.
Can you please suggest what's goes wrong in the below code...
#/usr/bin/python3.6.1

# import modules
import sys
import psycopg2
import datetime


#import cursors
now = datetime.datetime.now()
# current data and time
dt = now.strftime("%Y%m%dT%H%M%S")

# xml tree access
#from xml.etree import ElementTree
import xml.etree.ElementTree as ET

# incremental variable
x = 0
with open(sys.argv[1], 'rt',encoding="utf8") as f:
    	#tree = ElementTree.parse(f)
		tree = ET.parse(f)
# connection to postgreSQL database
try:
    conn=psycopg2.connect("dbname='####' user='postgres' password='XXXX'")
except:
    print ("Hey I am unable to connect to the database.")
cur = conn.cursor()
# access the xml tree element nodes
try:
	for node in tree.findall('.//tu'):
		src = node.find('tuv[1]/seg')
		tgt = node.find('tuv[2]/seg')
		
		source = src.text.encode("utf-8")
		target = tgt.text.encode("utf-8")
		
		#query to database table
		query = "INSERT INTO MT_DB (SRC_LOCALE,SRC_DATA,TGT_LOCALE,TGT_DATA,DOMAIN,DATETIME,TYPE) VALUES (%s, %s, %s, %s, %s, %s, %s)"
		data = (sys.argv[2],source,sys.argv[3],target,sys.argv[4],str(dt),sys.argv[5])

		#for locale swap with data
		#data = 

Open in new window

0
Is there is a simple way to send an email when the user has saved a new record in the database ?

We have a list of inventory in a warehouse that belongs to different businesses (hour clients), we need to send the business a message when is shippement has arrived to our ware house.

Please keep in mind that I'm very new to odoo, eed to know how to connect a pythod code to the model action of "on_creation"...
0
how to transpose csv in python to one coloumn

i want to transpose like this:

1 2 3
4 5 6
7 8 9

to
1
2
3
4
5
6
7
8
9

please help
0
I have a server which runs on PostgreSQL, Django on apache and gets hang up every couple of days. I understood that it would require PostgreSQL optimization. But there are so many parameters not sure where to start. As of now, the server hanging up. Please let me know what kind of information you need so that I can provide you and you can better assist me.

Also I have iptables firewall setup not sure where exactly is the problem. But the website hangs up every 1 one day and when I restart the apache it works for one day.
0

Python

3K

Solutions

23

Articles & Videos

2K

Contributors

Python is a widely used general-purpose, high-level programming language. Its design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than would be possible in other languages. Python supports multiple programming paradigms, including object-oriented, imperative and functional programming or procedural styles. It features a dynamic type system and automatic memory management and has a large and comprehensive set of standard libraries, including NumPy, SciPy, Django, PyQuery, and PyLibrary.